title: How to read file line by line in Bash script?
body: <p>I have a problem with reading a file line by line with bash script. Here is the script:</p>
  
  <pre><code>#!/bin/bash
  
  file="cam.txt"
  
  while IFS=: read -r xf1 xf2 xf3
  do
       printf 'Loop: %s %s %s\n' "$xf1" "$xf2" "$xf3"
       f1=$xf1
       f2=$xf2
       f3=$xf3
  done &lt; $file
  printf 'After: %s %s %s\n' "$f1" "$f2" "$f3"
  </code></pre>
  
  <p>Here is <code>cam.txt</code>:</p>
  
  <pre><code>192.168.0.159
  554
  554
  </code></pre>
  
  <p>Here is the output:</p>
  
  <pre><code>Loop: 192.168.0.159  
  Loop: 554  
  Loop: 554  
  After: 554
  </code></pre>
  
  <p>What could be the problem?</p>