 <p>It is because you are asking the program to read from the file <code>file.txt</code>:</p> <pre><code>done &lt;file.txt </code></pre> <p>Also looks like you have a typo here:</p> <pre><code>if [ $x = "true" ] ^^ </code></pre> <p>which should be <code>"$line"</code>. <br>Also note the <code>"</code>, without them your program will break if the word read from the file has a space in it.</p>