Using flock to wait for a lock file to be released