Use StringIO instead of reinventing the wheel
Merge branch 'stringio-stdout'