removed fflush, no buffering works