Help with for statement within while statement

I'm trying to do a for statement within a while read line statement and it's not working. What is wrong with this?

while read line
do
find . -type f -name "*.$line*" -exec gunzip {} \;
   for file in */*.$line*;
   do grep ERROR "*.$file*" > error.$line.log;
   done
find . -type f -name "*.$line*" -exec gzip {} \;
done

I'm getting this error when I execute this

grep: 0652-033 Cannot open *.sub_test/report.1102012359348881.log*.

---------- Post updated at 03:07 PM ---------- Previous update was at 02:42 PM ----------

I just bypassed the for statement and went with another find. command. But I'd still like to know how to make that work.

do grep ERROR "*.$file*" > error.$line.log;

$file is already the entire filename, adding * to the front and back isn't necessary.

Even if it was necessary, * doesn't work inside quotes for shell globbing. (it's necessary to put it in quotes for find just so the shell doesn't try and expand it itself first!)

I think you can do this all in one step, without temp files:

for FILE in */*.$line*
do
        gunzip < "$FILE" | grep ERROR > error.$FILE.log
done