fix input loop to properly handle backspaces