using while read line instead of for