by BillyBoyo » Wed Feb 04, 2015 7:53 pm
You don't know you have the last record, therefore the last-but one either, until you reach end-of-file.
You have to store a record. When you read the next record, it means you have the current, and the one before.
That's not completely there, as you need the one before that. So, when you read a new record, you store the previously stored record in another place, and store the current record. When you get end-of-file, you write out the "previously stored record in another place".
You have to take care of a couple of situations: empty file; file containing only one record. For the first perhaps DISPLAY "Disaster! File is empty!". For the second DISPLAY "There is only one record on the file, so can't write the penultimate one, sorry".