What do the logs tell you? As long as you don't look at the error file, your debugging is going to be just taking shots in the dark.
BTW, does flock work on Windows?
The last time I used locking (a while ago), I did not lock the file itself, but used a dedicated lock file: