--- setup.py
+++ setup.py
@@ -221,7 +221,9 @@
          script_str = "%s %s %%*\n" % (sys.executable, checker_path)
       else:
          script_str = '#! /bin/sh\n\n%s %s "$@"\n' % (sys.executable, checker_path)
-      open(script_path, "w").write(script_str)
+      script = open(script_path, "w")
+      script.write(script_str)
+      script.close()
    except Exception, e:
       print "ERROR: Unable to create %s: %s" % (script_path, e)
       raise e