Slight improvements of the error handling for opening and reading the file