Fix bug that prevent repeat line added to the end