If you've got your file in an array - one line per element, as per what you get out of the file() function...
Loop through the $array (foreach ($array as $linenumber=>$line)), keeping count of the number of times strpos($line, '<!--End of Article-->')!==false. When that gets to 5 , the current $line (number $linenumber) carries the end of the 5th article on the page. Everything above this line is kept, everything below this line is archived (modulo headers and footers) and the stuff on this current line depends on how lines wrap around in the file.