Problems reiterating values from txt file into a variable

Hi,

I have written a script to retrieve phone numbers from an error log and output the phone numbers into an text file. I then use the list of phone numbers to process each value into a variable so I can run a sql query and update the database. My problem is I can only process the first value (phone number) in the text file. I have tried using for loops and while loops with no success.

Phonelist.txt

07881456780
07990123456
09781234567
07202123456
07889122331

I've tried testing this with parsing the txt file into an array. However, I would to process each element one at a time until all the values in the text have been used.

set -A ctn $(</tmp/phonelist.out)
4 ctntotal=${#ctns
[]}
5 i=0
6
7 while [[ $i < $tntotal ]]
8 do
9 ctn=${ctns[i]}
10 sed "s/XXXXXXXXXXXX/$ctn/" $membersql >> $ctnsql
db2 connect to DB user ADMIN using admin
db2 -tf /tmp/ctnquery.txt > /tmp/queryres.out
11 unset ${ctns[0]}
12 ctntotal=`echo ${#ctns[
]}`
13 echo $ctntotal
14
15 done

Your help would be greatly appreciated!

#!/usr/bin/sh

db2 connect to DB user ADMIN using admin

while read NEW
do
echo $NEW
# OR what ever you want to do with the number
done < Phonelist.txt

That's worked. Thanks for your help.