Main loop that handles print exit and setValue