From: David Rio Date: 2011-01-26T11:16:13+09:00 Subject: Re: IO from text file Print the numbers of elements in lines. Most likely you have two blank lines at the end of the input file. Also, notice how you are using single quotation marks, so you ruby won't expand the value of the variable line. A more compact way to do it: -drd On Tue, Jan 25, 2011 at 4:46 PM, Michael Litton wrote: > I am trying to read in three strings from a .txt file. The code does > everything but return the values stored in the file. > > Code: > > f = File.open('productlines.txt','r') > lines = f.readlines > lines.each do |line| >  test = '#{line}' >  puts 'I read this line: ' + test +'.' > end > > File contents: > pkplus > aminoplex > tuffturf > > Output: > I read this line: #{line}. > I read this line: #{line}. > I read this line: #{line}. > I read this line: #{line}. > I read this line: #{line}.