From: terminate Date: 2009-03-06T01:13:35+09:00 Subject: Re: add a new line after, w/txtfile thats comma delimited On Mar 5, 11:10 am, Jesús Gabriel y Galán wrote: > On Thu, Mar 5, 2009 at 4:58 PM, terminate wrote: > > I'm new to Ruby but I just read a book that had an example that is > > similar to this.  I've changed the code to see if I can solve this > > problem and it seems to do it. > > > #code: > > > lines = File.readlines("temp.txt") > > values = lines.split(/,/) > > > output_file = File.open('output.txt', 'w') > > values.each do |line| > > output_file.puts line > > end > > Just a comment here. It's usually better to use the block form of open, > since that will take care of closing the file, even when an error happens: > > File.open('output.txt','w') do |output_file| >  #... > end > > Jesus. Thanks for the clarification Jesus!