Error handling in file operations