I think you misread my answer. I suggest you use the normal flock
locking facilities on a different file. It is not the mere presence
of the separate lock file that keeps others from accessing the file,
but the fact that you have an exclusive lock on that file. That
exclusive lock does get automatically removed.
There is no technical reason that the file you lock has to be the file
you modify, it is just a convention. As long as all writers use the
same locking procedure, things will work.
_.John