Added stdout flush for smoother animation.