Besides from that, your code looks fine, and works perfectly for the sample file you have provided. I suspect what might be happening is somewhere in your file you have the sequence "//\n" at say the end of a line inside a record, when you only really want to catch "//" appearing on a line by itself. You might try $/ = "\n//\n" to force this.

Be aware that you may end up reading an extra "empty" record at the end of your file if the last thing in your file is the input record separator.

Hi... thanks for the answer..
Actually the problem is the are a few blank lines at the end of the input file..
So after the last // there are a few blank lines which is impossible to be deleted for every case.
eg:

When putting a smiley right before a closing parenthesis, do you:

Use two parentheses: (Like this: :) )
Use one parenthesis: (Like this: :)
Reverse direction of the smiley: (Like this: (: )
Use angle/square brackets instead of parentheses
Use C-style commenting to set the smiley off from the closing parenthesis
Make the smiley a dunce: (:>
I disapprove of emoticons
Other