try flushing stdout in both cases