Use with statement where it improves the documentation (closes #10461)
diff --git a/Doc/library/difflib.rst b/Doc/library/difflib.rst
index a0afe81..505d308 100644
--- a/Doc/library/difflib.rst
+++ b/Doc/library/difflib.rst
@@ -750,8 +750,8 @@
        # we're passing these as arguments to the diff function
        fromdate = time.ctime(os.stat(fromfile).st_mtime)
        todate = time.ctime(os.stat(tofile).st_mtime)
-       fromlines = open(fromfile, 'U').readlines()
-       tolines = open(tofile, 'U').readlines()
+       with open(fromlines) as fromf, open(tofile) as tof:
+           fromlines, tolines = list(fromf), list(tof)
 
        if options.u:
            diff = difflib.unified_diff(fromlines, tolines, fromfile, tofile,