Get rid of ResourceWarning: unclosed file