you need to flush after each echo with
flush(); ob_flush();
Although it might not work because of server setting
flush() may not be able to override the buffering scheme of your web server and it has no effect on any client-side buffering in the browser. [...]
Several servers, especially on Win32, will still buffer the output from your script until it terminates before transmitting the results to the browser.
Server modules for Apache like mod_gzip may do buffering of their own that will cause flush() to not result in data being sent immediately to the client.