Fix correct error handling for file open failure.