I created a class with the responsibility to generate a text file where each line represents the information of an object of \'MyDataClass\' class. Below is a simplification
According to MSDN, WriteLine
Writes data followed by a line terminator to the text string or stream.
your last line should be
_streamWriter.Write(line);
Put it outside of your loop and change your loop so it doesn't manage the last line.