`getvalue()` can only be used before `close()` is called: http://docs.python.org/2/library/stringio.html#StringIO.StringIO.getvalue