You should probably just make the StreamWriter object before everything else and have it available until the loop has finished, then just write the newline
after the loop, like this:
using (StreamWriter sw = File.AppendText(@"C:\Users\yamald\Documents\Normal.data"))
{
for (int j = 0; j < bufferreader.Length; j++)
{
sw.Write(bufferreader[j] + ",");
}
sw.WriteLine("\n");
}
It's also probably better to use a while
loop and do something like while(bufferreader.length != null)
instead of the for
loop and if
statement, but that's up to you and I haven't used bufferreader in a while so wouldn't know the exact syntax for that.
However, the reason for why the else
never gets executed is (as EoiFirst correctly said) that you're not actually changing bufferreader.length so it won't ever be null.