I have written a loop to basically parse a string, and at every 50th
character check to see if is a  space, if not, work back until it
finds one, then insert a newline. I am turning masses of text (copy)
from a DB into images, and I just wanted to automate it, I was just
wondering if there are better ways of achieving what I am trying to
do.

        characterCount = 0
        positionCount = 0
        insertPoint = MAX_LINE_LENGTH

        while characterCount != copy.length
          characterCount += 1
          positionCount += 1
          if positionCount == MAX_LINE_LENGTH
            begin
              characterCount -= 1
              insertPoint -= 1
            end until copy[characterCount].eql?(ASCII_SPACE)
            copy.insert(characterCount+=1,'\n')
            imageHeight += LINE_HEIGHT
            positionCount = 0
          end

        end

Cheers,
Kev