add fflush to enable realtime showing