Don't use the CR (=(char)0x0d) (=\r) character unless you have been told specifically that it is required. As you can see, its behaviour is platform‑dependent. I tried your program on a Linux box and got
It is possible that your Eclipse installation has an option to take different line separator sequences and is set to “classic Mac” where the line end sequence is CR. I have no idea where that option is to be found. If you ever find it, try changing it to Windows/DOS (=CRLF =(char)0x0d(char)0x0a =\r\n) or Unix/Linux (=LF =(char)0x0a =\n). Newer Macs use the same line end as Linux.
Which operating systems were you using? cmd sounds like Windows[/edit]
I shall try duplicating this discussion in the IDEs forum; maybe somebody there will know more.