Added file lock function