flush stdout to print command string in correct order