Use the 'readline' module.