I want to read a file line by line, what could be the best way to achieve this?
Try something like this
while read line do echo $line done < $file
How trap command can help ?