Make usage of open safer by setting binary mode and closing fds

Signed-off-by: Shawn O. Pearce <sop@google.com>
diff --git a/editor.py b/editor.py
index a297470..34c9ad1 100644
--- a/editor.py
+++ b/editor.py
@@ -78,7 +78,11 @@
 
       if subprocess.Popen(editor + [path]).wait() != 0:
         raise EditorError()
-      return open(path).read()
+      fd = open(path)
+      try:
+        return read()
+      finally:
+        fd.close()
     finally:
       if fd:
         os.close(fd)