I'd be a bit concerned with that code. You're assuming Temp contains 4 elements, which is probably where your errors are coming from with a blank file. I'd highly suggest something along the lines of the following...
- while (...) { ... } // here is where you read your file
-
-
if (Temp.Length == 0)
-
{
-
// file is empty... or you may have to check each element of temp to see if it's "", but I think the readline won't put anything in here if it's blank
-
}
-
else if (Temp.Length == 4) // or perhaps some better comparison
-
{
-
// assign your variables
-
}
-
else
-
{
-
// Whatever you want this to be
-
}
A little error checking goes a long way! Also, personally I'd recommend putting the whole thing in a try/catch block. I like to do this when any kind of file access is involved because the possibility for unforseen error is so high. What I mean by that is, someone could delete your file while the program runs, or someone could have it open for write access. Again though, this is personal opinion... a lot of people don't like try/catch blocks because the involve a certain amount of overhead and indeed, in a more controlled environment I'd say do your error checking yourself, but for something with so many external factors, let the try/catch system handle it for you.