I have a flat file that I am using as a database currently it contains 7 records with 9 fields per record. the first field is refNum. the records are stored as standard input. What I want to do is to increment refNum by 1 automaticly when a new record is added. Logically I know that I have to find the last occurance of refNum, increase it by 1 refNum++ and write that new record with the new refNum. How do I code this?