title: How can I read standard input in a loop in bash, and then append the text to a file?
body: <p>Say I have a bash script as follows</p>
  
  <pre><code>while
   read $f;
  do
   cat $f &gt;&gt; output.txt;
   echo "aaa" &gt;&gt; output.txt;
  done
  </code></pre>
  
  <p>Yet the second <code>echo</code> statement isn't executed. At all. What am I doing wrong?</p>
  
  <p>I'm running this via</p>
  
  <pre><code>tail -f /var/log/somelog | ./script.sh
  </code></pre>
  
  <p><code>$f</code> should not be empty. It's only supposed to output when <code>tail</code> notices a change in the file.</p>