diff --git a/pyrser/grammar.py b/pyrser/grammar.py
index <HASH>..<HASH> 100644
--- a/pyrser/grammar.py
+++ b/pyrser/grammar.py
@@ -147,10 +147,8 @@ class Grammar(parsing.Parser, metaclass=MetaGrammar):
         """Parse filename using the grammar"""
         self.from_string = False
         import os.path
-        if os.path.exists(filename):
-            f = open(filename, 'r')
+        with open(filename, 'r') as f:
             self.parsed_stream(f.read(), os.path.abspath(filename))
-            f.close()
         if entry is None:
             entry = self.entry
         if entry is None:
Added: with statement in parse_file