From: Wyss Clemens Date: 2002-03-09T00:11:10+09:00 Subject: RE: Text stuff and appending to a file By heart I would guess: lines = File.readlines(ARGV[0]) # create a file to append data found from the input file logfile = File.open("badwords.txt", "w+") # search for a word and print the entire line lines.each { | line | if /bob/i =~ line print line logfile.write(line) end } Not tested though. Clemens > -----Original Message----- > From: bobx@linuxmail.org [mailto:bobx@linuxmail.org] > Sent: Freitag, 8. M�rz 2002 15:20 > To: ruby-talk@ruby-lang.org > Subject: Text stuff and appending to a file > > > I have the following that works: > > # open a file and read it > input = File.open(ARGV[0], "r") > > # create a file to append data found from the input file > logfile = File.new("badwords.txt", "w+").close > > # search for a word and print the entire line > while line = gets() > if /bob/i =~ line > print line > end > end > > I would like the lines that it finds with "bob" to print to the > console and append to the logfile. > > This is on Windows 2000.... > > Bob >