Unless I'm interpreting the script incorrectly, and I did recoil in horror fairly quickly, your friend seems to have rolled his own database. Whilst I'm sure he enjoyed the challenge, surely using DBX (or similar), i.e. an already tried and tested interface to a flat file database, is better in every way. I'd rewrite that if I were you, to something much more simple.