What is the function to flush a stdio stream from Elisp? If it exists then it could be called before the sleep-for.

An alternative to adding such a function is to simply have the print functions call fflush in C if noninteractive.