Unable to restore stdout to original (only to terminal),sys.stdout = sys.__stdout__