Added stdout flush