First working code. Runs in the terminal. CTRL-Z to stop.