We want to clobber the file, but we don't want to clobber the file until we've locked it. The catch is that one can't lock a file one doesn't have open, so we can't use open ">" to clobber the file. That means we have to start by opening the file without clobbering it (e.g. by using open ">>") and by locking it. Then, we're free to clobber it.