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

To give the time for any virtual serial port to initialise. It might not be long enough but it will stop the code from freezing when not connected to a USB port.