call fflush() at some places