StreamReader.ReadLine reads a string of characters from the current stream, and the position of the reader in the Stream base object increases by the number that the method could read. So, if you call this method a second time, you will read the next line from the base stream. The solution is simple - save the string in a local variable.
string line; while((line = reader.ReadLine()) != null) { array[i] = line; }
source share