Added error handling for file input