Flush stdout for trace sim to prevent incomplete file output during abnormal program exits