Fixed #6668 -- Optimise utils.text wrap

This fixes a failing test after applying an optimization of the
utils.text.wrap function by user SmileyChris.