Think this goes in the beginners section... 3 days worth of coding experience spread over a few months... anyway: I've been mucking with this code for the past few hours. I can go from actual file to actual file with no problem, if I type in a file that doesn't exist, then type in an actual file, the program gets stuck in the while loop, and infinitely repeats the last line of the last actual file read. If there was none last read, it outputs blank lines.
Please excuse the poor formatting, dropped the header file into the actual code to try and debug. Compiled on Vista x64 using the Code::Blocks IDE.
I tinkered with the file and found that if you put SongFile.clear(); between lines 70 and 71, your problem is solved. I believe that clear() fixes the error state that the SongFile object is in when you enter a bogus filename.
The problem is that if you try to open bad file (is not there, or something else) the state of stream also change.
Example:
If you open good file the state is 0 - goodbit. At the end of work with file you call clear and close and the state is 0 too.
But if you open bad file the state change to 2 after open operation and than you don't call close or clear. It means that the state stay 2. And if you try open again new file the state is still 2. So You must call clear before new open which change the state to 0.
You can check the state of stream by function rdstate().