first, i wouldnt use fstream... second, records[j].isDeleted == true is redundant. why not just make it records[j].isDeleted. third, we need more code. how else can we know from so little information?
First of all, you should ALWAYS test the stream first:
1 2 3 4 5
if(!output)
{
cerr << "Could not open file to write to";
return -1;
}
or similar.
Then, I would step through your program with the debugger to see what's happening. It's possible your if statement in the for loop never evaluates to true.