I know it's 2 years old, but...
If you are using the default Apple "terminal app" the problem is in the terminal and not in the app. By default it is set to declare itself as xterm-256color and that is the problem. Change it to ansi, and the program will behave as expected.
Besides changing the option in terminal preferences (advanced tab), you can do the quick check by examining TERM environment variable from within terminal, i.e.
$ echo $TERM
xterm-256color
$export TERM=ansi
$echo now, your program should behave correctly.
now, your program should behave correctly.