According to your description, the maximal value is at the end.
So, when you open the file to add a new record, seek back enough
and read the last number. Add one to that and store it next.
This example assumes that your record is at most 100
characters and that each record is white-space separated:
open(F,'myfile') or die;
$/='RECORD SEPARATOR';
seek F, -(101+length($/)), SEEK_END;
<F>;
while(<F>) { $max=(split)[-1]; }
print "New value can be ", $max+1, "\n";
(untested)
HTH