copied your code into my window and here are my debug errors, the program gets the error after the las line of good text from the .txt file:


'Week4 FileIO.exe': Loaded 'C:\Users\School\Documents\Visual Studio 2010\Projects\Week4 FileIO\Debug\Week4 FileIO.exe', Symbols loaded.
'Week4 FileIO.exe': Loaded 'C:\Windows\System32\ntdll.dll', Cannot find or open the PDB file
'Week4 FileIO.exe': Loaded 'C:\Windows\System32\kernel32.dll', Cannot find or open the PDB file
'Week4 FileIO.exe': Loaded 'C:\Program Files\AVAST Software\Avast\snxhk.dll', Cannot find or open the PDB file
'Week4 FileIO.exe': Loaded 'C:\Windows\System32\msvcp100d.dll', Symbols loaded.
'Week4 FileIO.exe': Loaded 'C:\Windows\System32\msvcr100d.dll', Symbols loaded.
First-chance exception at 0x7693fc56 in Week4 FileIO.exe: Microsoft C++ exception: std:ut_of_range at memory location 0x001bf4a8..
Unhandled exception at 0x7693fc56 in Week4 FileIO.exe: Microsoft C++ exception: std:ut_of_range at memory location 0x001bf4a8..
The program '[6784] Week4 FileIO.exe: Native' has exited with code 0 (0x0).