Slightly improve error handling when reading files