Add a lockfile function to append to a file