Replicate orrection #611 0.12 to master

ResourceWarning: unclosed file <_io.BufferedReader