Reset replaced lines before removing inserted lines