Move the try/except into the `with` block.