error handling for IO error and file not found