title: Writing output from a grep search into a single file
body: <p>I have for loop which I'm using to iterate through a list of keywords. I then search for each word in another file using the grep function and I'm writing it to another file. The problem is the program deletes everything from the previous iteration of the loop so I'm only left with the output from the last keyword in the file. How can I write each output to a new line of the same file?</p>
  
  <p>This is the code I have. I apologize for the noob question - I'm new to this. Thanks!</p>
  
  <pre><code>#!/bin/bash
  
  for i in $(cat file1.txt); do
          grep $i file2.txt&gt;file3.txt 
  done
  </code></pre>