title: "while read LINE do" and grep problems
body: <p>I have two files.  </p>
  
  <pre><code>file1.txt:  
  Afghans  
  Africans  
  Alaskans  
  ...  
  </code></pre>
  
  <p>where <code>file2.txt</code> contains the output from a wget on a webpage, so it's a big sloppy mess, but does contain many of the words from the first list.</p>
  
  <p>Bashscript:</p>
  
  <pre><code>cat file1.txt | while read LINE; do grep $LINE file2.txt; done
  </code></pre>
  
  <p>This did not work as expected.  I wondered why, so I echoed out the $LINE variable inside the loop and added a sleep 1, so i could see what was happening:</p>
  
  <pre><code>cat file1.txt | while read LINE; do echo $LINE; sleep 1; grep $LINE file2.txt; done
  </code></pre>
  
  <p>The output looks in terminal looks something like this:</p>
  
  <blockquote>
    <p>Afghans<br>
    Africans<br>
    Alaskans<br>
    Albanians<br>
    Americans<br>
    grep: Chinese: No such file or directory<br>
    : No such file or directory<br>
    Arabians<br>
    Arabs<br>
    Arabs/East Indians<br>
    : No such file or directory<br>
    Argentinans<br>
    Armenians<br>
    Asian<br>
    Asian Indians<br>
    : No such file or directory<br>
    file2.txt: Asian Naruto<br>
    ...  </p>
  </blockquote>
  
  <p>So you can see it did finally find the word "Asian". But why does it say:</p>
  
  <blockquote>
    <p>No such file or directory</p>
  </blockquote>
  
  <p>?</p>
  
  <p>Is there something weird going on or am I missing something here?</p>