>> after restarting gets an error System.ArgumentNullException' occurred in mscorlib.dll
This is because your file is blank and ReadLine() returns nothing, so null is being passed to Long.Parse(). You should consider checking the return of ReadLine() for null before passing to Long.Parse--even if you get the logic working correctly.
>> it all works except when it tries to write to the file nothing gets written
What kind of app is this? A windows service?
>> what os are you using
XP