replaced lockfile with flock