in reply to Beginner needs help

If the code is only a few lines, you are better to include more context, since the error may be triggered by previous lines.

are you using strict and warnings ?

"While" should be "while". I think this is your main problem, since PERL thinks this is a call to a function rather than a while statement, so the {} following the While causes the error.

You should also be checking the result of the open in case it fails.
--
Brovnik