I'm glad to see @ayust already came across this, but for what it's worth this bugged me, too.  I had to stroke my chin for a while to figure out what `context_manager` was (the variable name is not much more useful than `variable` would be).  Then I had to observe that `with` on a file object assigns that file object right back to the given variable, so in this case `outfile` is `context_manager`.  All of which is to say that, for a competent Python programmer, this caused quite a bit of mental churn. I like Amber's latest suggestion of passing paths to the read/write functions, as it keeps the open and close operations near one another.