why does using "continue;" still gives error?

So i was drafting a cute lil level up system (just a draft)…and i decided to use the array approach to tackle this…so i wrote this simple piece of code…whenever i run the CheckLevel() Method…unity says that the index doesn’t exist at cs: 37(which it doesn’t…but since im using…

if(levels[index + 1] == null)
{
  continue;
}

why does this still happen? Also, i realise that using return here would be the same, and that using these would mean that the last level of my array would not be checked…but why is this happening?
Im sorry if it’s something stupid…sorry and thanks in advance!

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;

[System.Serializable]
public class Level
{
  public string levelname;
  public int serial;
  public int requiredxp;
  public int extrajumps;
  public int health;
  public int attackstrength;
}

public class PlayerStats : MonoBehaviour
{
  public int coins;
  public int shadowxp;
  public int attacklevel = 1;
  public int attackstrength;
  public int level;
  public Level[] levels;

  [Header("Frame Counter")]
  public int lcframecount;
  public int activelccount;


    public void CheckLevel()
    {
      foreach(Level leveldata in levels)
      {
        int index = Array.FindIndex(levels, levels => levels == leveldata);
        leveldata.serial = index + 1;
        if(levels[index + 1] == null)
        {
          continue;
        }
        else if(shadowxp >= leveldata.requiredxp && shadowxp < levels[index + 1].requiredxp)
        {
          if(level != leveldata.serial)
          {
            level = leveldata.serial;
            Debug.Log("your level is " + level + " so you are now a " + leveldata.levelname);
            this.gameObject.GetComponent<PlayerMovement>().extrajumps = leveldata.extrajumps;
            this.gameObject.GetComponent<PlayerCombat>().maxhealth = leveldata.health;
            attackstrength = leveldata.attackstrength;
          }
        }
      }
    }

    void DebugLevels()
    {
      foreach(Level leveldata in levels)
      {
        leveldata.serial = Array.FindIndex(levels, levels => levels == leveldata) + 1;
      }
    }

    void Start()
    {
      activelccount = lcframecount;
      CheckLevel();
    }

    void Update()
    {
      if(activelccount > 0)
      {
        activelccount--;
      }
      else if(activelccount <= 0)
      {
        CheckLevel();
        activelccount = lcframecount;
      }
    }
}

It does look like a simple IndexOutOfBounds exception to me.

When you are the last index you just can’t check the array for “Index + 1”, you should just check for “index < size -1” before if you want to access “index + 1” in an array.