remove several race conditions around lock file by opening it once
syntax fix
Merge pull request #159 from openquery/lock

remove several race conditions around lock file by opening it once