Designing string tokenisers

Char *mystrtok(char str,char delim)
{
static char
input = NULL;
if(str!=NULL)
{
input=str;
}

  if(input==NULL)
  {
        return NULL;
   }

  char *output=new char[strlen(input)+1];
  int i= 0;
  for( ; input[I]!='\0';i++)
  {
       if(input[i] != delim)
       {
            output[I] = input[i];
        }
       else
       {
            output[i] ='\0';
            input=input+i+1;
            return output;
    }
}
//Corner case
output [i] = '\0' ;
input =NULL;
return output;

}

my question is why here sir used if(input==NULL)
{
return NULL;
}

In for loop sir already made this condition that
input[I] != ‘\0’

this condition will be executed at end when all tokens are extracted
and nothing is left then your input ==NULL
at that time you also have to return NULL

to handle this last case sir have made this condition

But in corner case this condition is covered .And in corner case Output[i] is also asigned to ‘\0’ which acts as null .

if input is null then this will not throw an error
strlen(NULL);