bpo-22831: Use "with" to avoid possible fd leaks in tools (part 2). (GH-10927)

diff --git a/Tools/unicode/gencjkcodecs.py b/Tools/unicode/gencjkcodecs.py
index ebccfc7..45866bf 100644
--- a/Tools/unicode/gencjkcodecs.py
+++ b/Tools/unicode/gencjkcodecs.py
@@ -61,7 +61,8 @@
                                        encoding=enc.lower(),
                                        owner=loc)
             codecpath = os.path.join(prefix, enc + '.py')
-            open(codecpath, 'w').write(code)
+            with open(codecpath, 'w') as f:
+                f.write(code)
 
 if __name__ == '__main__':
     import sys