Bob X <bobx / linuxmail.org> writes:

> It parses, it opens, but it doesn't write to the outFile. So I am
> guessing I am not looping through the array properly.
> 
> 
> #!/usr/bin/ruby -w
> 
> # populate the array
> kw = [ "adult", "teen" ]
> 
> # create a file to append data found from the input file
> inFile = File.open(ARGV[0], "r")
> outFile = File.new(ARGV[1], "w+")
> 
> # search for a word and print the entire line
> inFile.each_line { |line|
>      for kw in line    # keywords to search for

THis overwrites your kw array with 'line'

Try something like (untested)

     for word in kw
       if line.include?(word)
  	print line	  # let the lines print to console
 	outFile.write line	# also print to file
      end
     end


Cheers


Dave