cherry picked cb5d027b about context managers
[nepi.git] / src / nepi / resources / omf / application.py
index 14f78f3..86c82cb 100644 (file)
@@ -286,13 +286,11 @@ class OMFApplication(OMFResource):
 
         if attr == TraceAttr.ALL:
             try:
-                f = open(trace_path ,'r')
+                with open(trace_path ,'r') as f:
+                    return f.read()
             except IOError:
                 print("File with traces has not been found")
                 return False
-            out = f.read()
-            f.close()
-        return out
 
 
     def do_start(self):