The other thing I could look into doing is modifying the underlying regex'es so that

so.stderr.each_line do |line|

works.