title: Array of integers from file
body: <p>I am trying to grab large numbers from a file, store them as an array, and add them up.</p>
  
  <pre><code>nums = Array.new
  x, total=0, 0
  file = File.open("inputfile.txt", 'r')
  while !file.eof?
    nums[x] = file.readline
    x+=1
  end
  
  while x&gt;0
    x-=1
    total += nums[x]
  end
  
  puts total
  </code></pre>
  
  <p>When my code executes, I get an error saying:</p>
  
  <pre><code>String can't be coerced into Fixnum (TypeError)
  </code></pre>
  
  <p>I checked to make sure that each array element actually has the right data in it. I think that the numbers are considered strings when stored. If that's the case, how would I change the array to integers so I can total them up?</p>