Added check for IO errors in load_file