Use readline's callback interface instead of implicit busy polling.

Closes PR 13350.