I have a problem on the client’s site, where lines containing words like “Habit” are distorted upon exit. I am processing a text file (pulling out the selected lines and writing them to another file)
For diagnostics, I welded the problem to a file with this bad word.
The source file does not contain a specification, but .net selects it as UTF-8.
When read and written, the word ends as if it were Habitao.
The hash dump of the BadWord.txt file is as follows:

Copy file using this code
using (var reader = new StreamReader(@"C:\BadWord.txt")) using (var writer = new StreamWriter(@"C:\BadWordReadAndWritten.txt")) writer.WriteLine(reader.ReadLine());
., gives.,.

Saving reader encoding does nothing
using (var reader = new StreamReader(@"C:\BadWord.txt")) using (var writer = new StreamWriter(@"C:\BadWordReadAndWritten_PreseveEncoding.txt", false, reader.CurrentEncoding)) writer.WriteLine(reader.ReadLine());
., gives., 
Any ideas on what is going on here, how can I process this file and save the source text?
source share