loading a file with error handling