Switched to manual control of stdout.

Because Python doesn't have support for terminal-like functionality like
remembering previous commands, I am switching over to manually controlling
what gets printed to stdout. This commit was mainly refactoring, and
as such the behavior of the program should be exactly the same as it was
(save for it only allowing 70 characters for input now. If the user types
really fast it was letting them enter more than one line and the code
that cleared lines broke)