I am trying to read data from a file, test it, sort it, then write it to a file. I am able to sort the data but only the last lines that are sorted as bad or good by the program are written out. How do I fix this?
I don't understand how lines 43 and 49 even compile in the first place - output streams use the shift left operator << and not the shift right operator >> like input streams do.
As for what you're experiencing, when you open a file stream it starts at the beginning, so you just overwrite the existing data. Use the ios::app flag when opening to start at the end.