You need to comment the while(!Serial). This line will stop the sketch until the Serial Monitor or Plotter window is opened.