Changed to using flock for locking