I know this is shitty code from me (which I stole from pip I think), but I’d suggest to do it more cleanly and use a `with`-block so the file gets closed afterwards.