Since working with CSV files (comma separated values) is so common, Ruby has a whole library of methods designed just for that purpose.
Require the csv library at the top of your file to get access to this magical kingdom of wonder:
require “csv”
Then you can call built-in methods, instead of rolling your own. Here’s one that iterates over each item in a csv file:
CSV.foreach(filename, some_optional_stuff)