Add main() function and call from __main__
Add readline support