title: WHILE loop - read line of a file one by one -- Not working the No. of times the file has lines in it
body: <p>I'm using a &quot;while&quot; loop within a shell script (BASH) to read line of a file (one by one) -- &quot;Fortunately&quot;, its not working the No. of times the file has lines in it.</p>
  <p>Here's the summary:
  $ cat inputfile.txt</p>
  <pre><code>1
  2
  3
  4
  5
  </code></pre>
  <p>Now, the shell script content is pretty simple as shown below:</p>
  <pre><code>#!/bin/bash
  
  while read line 
  do
   echo $line ----------; 
  done &lt; inputfile.txt;
  </code></pre>
  <p>The above script code works just fine..... :). It shows all the 5 lines from inputfile.txt.</p>
  <br/>
  <br/>
  <p>Now, I have another script whose code is like:</p>
  <pre><code>#!/bin/bash
  
  while read line 
  do
   echo $line ----------;
  
   somevariable=&quot;$(ssh sshuser@sshserver &quot;hostname&quot;)&quot;;
   echo $somevariable;
   
  done &lt; inputfile.txt;
  </code></pre>
  <p>Now, in this script, while loop just shows only line &quot;1 ---------&quot; and exits out from the loop after showing valid value for &quot;$somevariable&quot;</p>
  <p>Any idea, what I'm missing here. I didn't try using some number N &lt; inputfile.txt and using done &lt;&amp;N way (i.e. to change the input redirector by using a file pointed by N descriptor)
  .... but I'm curious why this simple script is not working for N no. of times, when I just added a simple variable declaration which is doing a &quot;ssh&quot; operation in a child shell.</p>
  <p>Thanks.</p>