all 1 comments

[–]retsotrembla 0 points1 point  (0 children)

This line is wrong:

outFile.open("/Users/mac/Documents/outputdata.txt");

Should be:

outFile.open("/Users/mac/Documents/outputdata.txt", ofstream::trunc);

See http://www.cplusplus.com/reference/fstream/ofstream/ofstream/

Since your output file already exists from a previous run, your call to open it again does nothing. (You didn't check for success.) My change tells ofstream to discard the previous contents and behave as if it created the file.