From: Andy Dbest Date: 2008-06-08T23:05:56+09:00 Subject: Search File Contents Hi Guys, I have a small code block that is frustrating me for some time now. I want to search for some text in a file. Simple isnt it? def read_file week_num week_num = week_num.to_s f = File.open("fixtures.txt", "r") lines = f.readlines #week_num = '1.' lines.each do|line| if line.chomp.eql? week_num puts "Found the week number" end end f.close end The above is the method, and I am searching for "1.". I am passing the variable "week_num" and i even tried to convert it to string. The search code as it is right now, does not output "Found the week number", even though the file contains "1." If i uncomment the line that assigns week_num to '1.' directly, then it works. What am i doing wrong? -- Posted via http://www.ruby-forum.com/.