What is the error message that you're getting when you've deleted the last record?

It could be that if you're in a loop to read one record at a time, once you've deleted the last record on move to the next record, you're at the end of file (.EOF) and there's nothing to read/delete. Maybe you should try counting the number of records in the table first, then set your counter to go through that number of records only. Or, you could delete records until .EOF is true.