One key thing that bit me (it's in the documentation; I just missed it) is that to get the result out you use #string, not #to_s. #to_s just tells you it's a StringIO. #string gives you the built result.
– James A. RosenJun 09 '09 at 12:13
See also http://stackoverflow.com/questions/10323/why-doesnt-ruby-have-a-real-stringbuffer-or-stringio
– James A. RosenJun 09 '09 at 12:13