StreamWriter has some options of usage. You can as add new text to an existing text in file, so and to clean existing text and add a new one.

The 6th option of usage StreamWriter is (string path, bool append, Encoding encoding)

To truncate data in a file, you should use something like this:

 

If you want to add new text to a file, use true instead of false: