diff --git a/zenmap/zenmapCore/UmitConfigParser.py b/zenmap/zenmapCore/UmitConfigParser.py index 0754e9fa0..4df9e1cfe 100644 --- a/zenmap/zenmapCore/UmitConfigParser.py +++ b/zenmap/zenmapCore/UmitConfigParser.py @@ -88,12 +88,12 @@ class UmitConfigParser(ConfigParser): if self.filenames: log.debug("saving to %s" % self.filenames) try: - fp = open(self.filenames, 'w') + with open(self.filenames, 'w') as fp: + self.write(fp) except Exception as e: self.failed = e log.error(">>> Can't save to %s: %s" % (self.filenames, e)) return - self.write(fp) self.failed = False else: log.debug(">>> UmitConfigParser can't save changes: no filename")