in reply to record separators
To me it looks like you are spending a lot of time reinventing the wheel (and not a very useful version, that is). Why aren't you just using one of the many indexed file formats readily available, such as DB_File?