I would suggest to keep on reading from the file using
read instead.
The [ error is probably because you forgot to put in the < where I indicated. It might help to add a statement to print the variables just before the
while so you can see what is getting compared.
Code:
echo "Here we are just before the while -- count is '$count' and i is '$i'"