I understood you the first time. The thing I fail to agree on is how you see single-incrementing values as sprawling out of control on what is evidently not going to become such a large file anyhow.
What you'll need to do is a bit crazy:
First, you'll need to explode the contents of the file into an array by line.
Then you'll have to loop through the array and get the ID of each line as you go. But save the ID to a temporary variable. You'll need it.
When you get to the next line and have the ID, you'll have to add 1 to the temp variable and compare it with the current variable. If they match, save that ID to the temp variable and move on. If they don't match, you've found a deleted value, and you now have your variable.
Then what do you do? You'll have to rewrite your file to that point and append the value to the end of the file - or write it there and then continue rewriting the entire file. If my guess is correct, you'll be rewriting your entire database file every time you insert, update, and delete. That is insane.
And I still don't get how the size of the file is not important, but you're concerned about the IDs sprawling out of control? This makes no sense.
But there you have it, an easy enough solution if you have an extremely low-traffic database and few extra hours on your hands.
