How to fix ResourceWarning: unclosed file in Python | DevErrors