Use `with` to scope fd lifetime. (#75)

* Use  to scope fd lifetime.

* Additional "with" scopes for rule_extractor.
diff --git a/skydoc/load_extractor.py b/skydoc/load_extractor.py
index 146ed6a..9863a67 100644
--- a/skydoc/load_extractor.py
+++ b/skydoc/load_extractor.py
@@ -33,7 +33,9 @@
     """Walks the AST and extracts information on loaded symbols."""
     load_symbols = []
     try:
-      tree = ast.parse(open(bzl_file).read(), bzl_file)
+      tree = None
+      with open(bzl_file) as f:
+        tree = ast.parse(f.read(), bzl_file)
       key = None
       for node in ast.iter_child_nodes(tree):
         if not isinstance(node, ast.Expr):
diff --git a/skydoc/rule_extractor.py b/skydoc/rule_extractor.py
index 28e2e93..6bc9360 100644
--- a/skydoc/rule_extractor.py
+++ b/skydoc/rule_extractor.py
@@ -93,7 +93,9 @@
       load_symbols: List of load_extractor.LoadSymbol objects containing info
         about symbols load()ed from other .bzl files.
     """
-    compiled = compile(open(bzl_file).read(), bzl_file, 'exec')
+    compiled = None
+    with open(bzl_file) as f:
+      compiled = compile(f.read(), bzl_file, 'exec')
     skylark_locals = {}
     global_stubs = create_stubs(SKYLARK_STUBS, load_symbols)
     exec(compiled) in global_stubs, skylark_locals
@@ -145,7 +147,9 @@
       bzl_file: The .bzl file to extract docstrings from.
     """
     try:
-      tree = ast.parse(open(bzl_file).read(), bzl_file)
+      tree = None
+      with open(bzl_file) as f:
+        tree = ast.parse(f.read(), bzl_file)
       key = None
       for node in ast.iter_child_nodes(tree):
         if isinstance(node, ast.Assign):