Modified text printer to simplify redirection and restoring of sympy printing.