New context manager to catch the output.

This variant does not leak file descriptors.