Index: lib/rexml/formatters/pretty.rb =================================================================== --- lib/rexml/formatters/pretty.rb (revision 18162) +++ lib/rexml/formatters/pretty.rb (working copy) @@ -127,7 +127,7 @@ def wrap(string, width) # Recursively wrap string at width. return string if string.length <= width - place = string.rindex(' ', width) # Position in string with last ' ' before cutoff + place = string.rindex(' ', width) || width # Position in string with last ' ' before cutoff return string[0,place] + "\n" + wrap(string[place+1..-1], width) end