AttributeError should not happen here.
Using with for opening files.