Changed lock_file() and unlock_file() functions