Don't do 'flock ON, 8', the lock will be released when the file is closed. Although very unlikly, by unlocking the file it is posible on some systems that the file will be grabbed by the next process before your script flushes it's output (never happened to me, but my co-worker thinks that it has happened to him once on an old sco box).