The nature of while loop makes it quite difficult. For the task at hand (processing a file line by line), I can come up with few solutions, but none that I would recommend.
- count lines before the actual processing, i.e. process the file twice. wc -l might help.
- stat the file to get its size and then count bytes processed.
Usually, in a console script, I'd settle for printing a dot every few lines.
UPDATE: As pointed out by GrandFather in a very similar topic today (Estimate line count in text file), you can use tell to detect your position inside the file. That together with detecting the size of the file gives quite a nice solution.