You are printing 5 MB to the browser and it is slow? So where's the bottleneck?
The bottleneck is clearly the net and/or the rendering speed of the browser, but not the IO of the script. Regardless how fast the net is, the harddisk is faster. So there's no need for optimization here. Well, maybe get a better server.