title: Read a Ruby string one character at a time (for word wrapping)
body: <p>I know this question is a fundamental one. I am able to take user input for a string and for an integer using:</p>
  
  <pre><code>str = gets()
  num = gets().to_i
  </code></pre>
  
  <p>But I want to read from the String(say which is in my case more than a line in length) character by character and count the number of characters from the first to the very last for every character encountered in the string. I know this can be achieved through:</p>
  
  <blockquote>
    <p>str.length</p>
  </blockquote>
  
  <p>I want to count it character wise as I am trying to implement <strong>word wrap</strong> in Ruby, wherein say within the line width(which would be a user defined number input) I would want to print only those words which are not continuing over to the next line i.e. I don't want to split a continuous word over two lines. Such words should be taken to the new line.</p>
  
  <p>Thanks for you time..!!</p>