in reply to search for blank lines by RegEx

I suspect $line only holds one line, so that what's preventing the regexp you presented from working.

Someone recently asked a similar question. You can check out our answers in this thread.