open(F, '+) { push(@addrs, tell(F)) unless eof(F); } truncate(F, $addrs[-2]) || die 'cannot truncate afile.txt';