Having issues with the Serial Monitor needing to be opened for my entire code to work

I think that the } was not removed :wink:

    while (!Serial) {
      ; // wait for serial port to connect. Needed for native USB port only
    } <<==== this one