USB Serial on Leonardo is affecting a sketch

  for (i=0;i<21; i++)

{
    ticket[i]=Serial1.read();   
  }

Perhaps you should check if serial data is available first? 21 bytes of it in this case.