I'm trying to delete a line from a Db file that I've created.

I'll explain:

I'm making a Db of people, which is consisted of id, first and last names - each one in a different line.

When I want to delete a record, I wanted to copy the part of the file after the record to another file, then copy it back to the position the record started (i.e the same data just one line before):


while (dataBase.peek()!=EOF)
		// copy a char to the temp file

while (fileToCopy.peek()!=EOF)

the problem is that the last line of the file is there twice - once from the new copy and one from the original file.

Is there a "smart" solution for that problem?
The other solution I have is copy the whole file beside the record-to-delete, then rename the new file to the original's name.