diff --git a/temporal/t.unregister/t.unregister.py b/temporal/t.unregister/t.unregister.py index cacfe579a7b..a67ef91adb5 100755 --- a/temporal/t.unregister/t.unregister.py +++ b/temporal/t.unregister/t.unregister.py @@ -103,17 +103,16 @@ def main(): # Read the map list from file if file: - fd = open(file) - - line = True - while True: - line = fd.readline() - if not line: - break - - mapname = line.strip() - mapid = dummy.build_id(mapname, mapset) - maplist.append(mapid) + with open(file) as fd: + line = True + while True: + line = fd.readline() + if not line: + break + + mapname = line.strip() + mapid = dummy.build_id(mapname, mapset) + maplist.append(mapid) num_maps = len(maplist) update_dict = {}