An if-statement is a good idea. 
For more flexibility, one could even check against number of scenes:
if (currentLevel < SceneManager.sceneCountInBuildSettings)
{
// code
}
An if-statement is a good idea. 
For more flexibility, one could even check against number of scenes:
if (currentLevel < SceneManager.sceneCountInBuildSettings)
{
// code
}