Your context is a little vague, but I think your issue is with string interpolation. If you change from single to double quotes, that will tell the interpreter to interpolate any variables encountered, i.e.
print FILE in{"REPORTID_$linecounter"};
You could also get the same result using the concatenation operator (.), i.e.