Doh! I forgot Ruby has mutable strings. I expected "s << something" to be the same as Python's "s += something". However, in Ruby "<<" actually modifies the string. That's really bad if there are any objects that have a pointer to the same string and aren't expecting it to be modified.
(I'm not criticizing Ruby. I just wasn't expecting it. I would never make that same mistake with something I knew was modifiable, like a hash.)