Changed the regex that  matches against the <body> element. Previous regex would eat anything after the body tag if there is no neew line in between