That means "append to".
What the routine does is read a line, append it to the buffer, read another line, append it to the buffer, and so on.
incidentally,
if ($i == 5) {
should read
if ($i < 5) {
It would have returned the first 6 lines in the first version.