overindented - fixed

Moved code that did not need to be in the context manager outside of it.