Yeah, I saw it. There are two options here: disable output buffering (which is what causes it), or write a function that does what readfile does but without overloading the memory.