Simple. Here is from PHP manual:
"Reading ends when length - 1 bytes have been read, on a newline (which is included in the return value),..."
You didn't include new-line char.
I suggest you to change your while:
while (strstr($buffer, $StrLimit))
or
while (ereg($StrLimit, $buffer))
or
while (strcmp(chop($buffer), $StrLimit))
With ereg(), you have to be carefull about special characters (square brackets, plus,...).
Hope this helped,
Vedran