Serial Monitor Not displaying anything - Arduino 1.8.9

My serial monitor will open but it is not displaying anything. I'm using Arduino 1.8.9 and a due. I'm just trying to get it to display something before I continue on other projects, but nothing is showing up.

void setup() {
  Serial.begin(9600);
  while(!Serial) { delay(100); }
}

void loop() {
  Serial.println("Hello!");
  delay(1000);
}

I have tried changing to different baud rates, I have disconnected the arduino and

Follow up: My serial monitor is not working either. They both will open, but both remain completely blank. I've tried both under several different scripts and a handful of different devices. I tried to reinstall the IDE. I'm not really sure what else to do.

Do you have the Board, Processor and Port selected correctly from Tools menu?

I do, yes. I've been writing and running other things all day, and I've been making due by writing to a little OLED display, but I'm at a point where I'm needing the monitor.

For anyone it helps, I didn't realize that the serial monitor would not display anything on my Due when connected to the Native USB. It only functions for me under the programming port. I was on Native because that is the only port that will load any code for me.

You can print to Serial Monitor using the Native USB Port as well. You need to use the correct object name for it though. Serial is for the Programming Port. SerialUSB is for the Native USB Port.

The other tricky thing is that, when using the Native USB Port, the microcontroller will not be reset when you open the Serial Monitor. That means anything printed before you get the Serial Monitor open will be lost. The solution is to add the following line before the first print:

while (!SerialUSB) {}

That will cause your code to hang in an infinite loop until the Serial Monitor is opened. For this reason, you would not want to add that line if you were planning to run your code without a serial connection open.

So if you were using this code with the Programming Port:

void setup() {
  Serial.begin(9600);
  Serial.println("hello");
}

void loop() {}

The equivalent for the Native USB Port would be:

void setup() {
  SerialUSB.begin(9600);
  while (!SerialUSB) {}
  SerialUSB.println("hello");
}

void loop() {}