From: Mmcolli00 Mom Date: 2008-12-02T23:39:55+09:00 Subject: opening/reading a text file - how do u use .find method? Here I am creating a text file, writing to the text file and then opening the text file to search for one of the lines that I just inserted this line contains 'wed'. My issue is that when I try to search the file using the .find and a regular expression the file does not even enter my if statement. (This is very beginner level I know) What do you think or suggest that I am doing wrong here? MC File.open('mynewfile.txt', 'w') File.open('mynewfile.txt', 'a') do |f1| f1.puts "00834 tue z0sdf" f1.puts "01230 wed z0sdf" f1.puts "34234 tue wet0f" end ##-----> Here is my troubled code... File.open('mynewfile.txt', 'r') do |f1| f = File.new("mynewfile.txt") newline = f.each {|line| puts "#f.lineno}: #{line}"} if f.each{|line| puts "#f.lineno}: #{line}"}.find =~ /wed/ varWed = newline end end -- Posted via http://www.ruby-forum.com/.