There was a typo in the regexp. I send the correction to the list just 
in case someone copies the code from the list archive:

>   (let ((regexp "^\\(?:[ \\t]*end\n\\)+"))

should be

    (let ((regexp "^\\(?:[ \t]*end\n\\)+"))

-- fxn