Working on file locking and better error handling for file operations.