Properly deal with indexes if the new line is also an index