Well, the idea is basically correct. Of course, such parsing is rigid and fragile, as a little change in format would break the functionality. Of course, it can be improved, but only slightly.
The fix you need is this:
using (StreamReader sr = new StreamReader("TestFile.txt")) {
string line;
while ((line = sr.ReadLine()) != null) {
string arr[] = line.Split(new char[] {' '}, System.StringSplitOptions.RemoveEmptyEntries);
}
}
Pay attention:
System.StringSplitOptions.RemoveEmptyEntries
will add some stability, in case you have more than one blank space or other complication (you can combine several separators making a first parameter a character array).
And you don't other fields because… 5 next lines are commented out. :-)
Add them again, as far as I can see, they should work. Run it all under debugger. Even the minimal debugging skills will help you to get it right in no time.
Good luck,
—SA