The 'leaving a trail' problem is a common one. You need to separate out the various elements of your drawing code. What's happening now is you're telling it to draw an @ at a particular point, wait for input, and then draw him at another point. The vital element here is that you aren't drawing back where he used to be, and it'll just leave the old @ there.
Typically you'd want something like this:
renderLoop():
while 1:
getInput()
check to see if this input is valid
if it isn't, oh no, print something and call renderLoop() again
actually this is probably better spun out into the actual getInput() function i dunno
if it is valid, hoorah:
move the character in the 'entities' layer
do whatever with anything else - AI, changes to the 'map' layer or whatever
get a combined form of the 'map' layer, entities layer (this is your 'viewport' or visual layer, the only one that gets drawn)
draw that combined layer
if 1 != 1:
shiiiiiit
throw a spaz
There are doubtless more efficient and better ways to do this, but I like the 'think of everything as a layer like in Photoshop' approach. You keep everything as separate as possible, move / alter them only in the layers that make sense, and then the final step is rendering it all to the layer that you actually see, which exists entirely independent of all the other layers and exists only to provide visual output.