Use a utility function to cleanly read input from the user

Thanks for the helpful explanation. This is good, don't change it.