From: "David A. Black" Date: 2009-09-18T10:28:51+09:00 Subject: Re: Value isn't appended in puts statement(appears on next line) --1926193751-291245391-1253237315=:26755 Content-Type: MULTIPART/MIXED; BOUNDARY="1926193751-291245391-1253237315=:26755" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --1926193751-291245391-1253237315=:26755 Content-Type: TEXT/PLAIN; charset=iso-8859-1; format=flowed Content-Transfer-Encoding: 8BIT Hi -- On Fri, 18 Sep 2009, Glenn Jackman wrote: > At 2009-09-17 03:01PM, "Jes�s Gabriel y Gal�n" wrote: >> File.open("directory") do |file| >> while somedigit =3D file.gets >> somedigit.chomp! >> puts "SQL STATEMENT I MADE UP =3D'"+somedigit+"'" >> end >> end >> >> In summary, gets returns the \n at the end of the line, so you should remov= >> e it. > > This form of file reading is somewhat more succinct: > > File.foreach('filename') do |line| > line.chomp > line.do_something_with_me > end You'll need chomp! though (or line.chomp.do_something). David -- David A. Black, Director Ruby Power and Light, LLC (http://www.rubypal.com) Ruby/Rails training, consulting, mentoring, code review Book: The Well-Grounded Rubyist (http://www.manning.com/black2) --1926193751-291245391-1253237315=:26755-- --1926193751-291245391-1253237315=:26755--