I got it to work better now, but it does not work as it is supposed to.
BTW I am using structs.
It never seems to detect eof.
if (file.eof() == true || times == 9) { break; }
The output I get is right except it does not stop when it is supposed to.