Use readline. Complete rewrite