Only flush stdout after write