posts archive page – closing WP_Query loop correctly [closed]

delete the following line of code

if ( ( $posts->current_post + 1 ) === $posts->post_count )
        echo '</li>';

leaving only the following portion

 <?php
        
    $last_year = $year;

    endwhile;

?>