If there's an error opening the file, `fd` won't exist, so this will raise a NameError.