Add fflush to prevent stdout & stderr from being mixed.