To behave like readline's history, you also need to make sure this line is not the same as the last one.