If you’re using File.OpenWrite() to create the output file, make sure the output file does not exist. This MSDN article explains what happens if output file exists:
For an existing file, it does not append the new text to the existing text. Instead, it overwrites the existing characters with the new characters. If you overwrite a longer string (such as “This is a test of the OpenWrite method”) with a shorter string (such as “Second run”), the file will contain a mix of the strings (“Second runtest of the OpenWrite method”).