From: Zoe Phoenix Date: 2008-05-31T08:15:08+09:00 Subject: splitting help needed I have a program that someone on this forum helped me fix before that took a list of cities formatted like: New York | Chicago | Boston | and formatted them like this, along with a phrase added after each one: New York Chicago Boston etc. The code looks like this: main = 0 full= File.open("state.txt") phrase=[", New Jersey"] count=0 inside = [] full.each do |line| first=[] first=line.split(/\|/) first.each do |single| sub=single.strip! main = (sub).to_s + (phrase).to_s inside << main newfile=File.new("state2.txt", "w") newfile.puts inside newfile.close count+=1 end end I tried to modify it so that it would separate not on the '|' character, but on a single space (such as in a list of cities like "New York Chicago Boston", etc. without the '|' above) and then enter the phrase after it. I can't seem to get it to put each city in the file on a new line and then add the phrase that I want after it like it did before. The only real difference in what I want now and what I had before was the '|' character. Can someone help me fix this? -- Posted via http://www.ruby-forum.com/.