finally working after sdout.flush()