Writing to a File Without Deleting What's Already There

I have this script that I want to not override whats in a file already but just append the text to the end.

function WriteToFile(){
    var file = StreamWriter(Application.dataPath + "/myFile.txt");

    file.Write("?");

    file.Close();
}

Like I said how do I make it so that the “?” gets written to the end of the file instead of deleting what’s there then writing it?

Searching with google (for msdn StreamWriter append) gave me: StreamWriter Constructor (System.IO) | Microsoft Learn. Does that help?

I can’t think of a way to add stuff at the end of the line but to add a new line u use Console.WriteLine method. It doesn’t override.

Otherwise u need to read those already exist in the file and covert them to strings then edit. To do that u use the StreamReader.ReadLine method abd remember to write them back in the file.

Hope this can help u, cheers!