python stdout flush not working