#8522: use with statement instead of try-finally for file handling.
diff --git a/Doc/howto/doanddont.rst b/Doc/howto/doanddont.rst
index f0c688b..05d8df9 100644
--- a/Doc/howto/doanddont.rst
+++ b/Doc/howto/doanddont.rst
@@ -232,11 +232,8 @@
 and perhaps not at all in non-C implementations (e.g., Jython). ::
 
    def get_status(file):
-       fp = open(file)
-       try:
+       with open(file) as fp:
            return fp.readline()
-       finally:
-           fp.close()
 
 
 Using the Batteries