with open(...) as fid:

...