Fix off by one error when finding closest line number for an element