getting next scene name

so i need to get a string value of the name of the next scene in the build settings.

    int currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
    string nextSceneName = SceneManager.GetSceneByBuildIndex(currentSceneIndex + 1).name;
    print(nextSceneName);

this feels like it should work however it is always returning “Null”

I found the implementation from another answer here, but this is what I added to my code eventually:

public static string NameOfSceneByBuildIndex(int buildIndex)
{
    string path = SceneUtility.GetScenePathByBuildIndex(buildIndex);
    int slash = path.LastIndexOf('/');
    string name = path.Substring(slash + 1);
    int dot = name.LastIndexOf('.');
    return name.Substring(0, dot);
}

This works for getting the names of scenes by buildIndex.