get the correct end line for a section