I have also experienced this bug as well as other corruptions of the Serial Monitor data. I have not found the specific circumstances this one occurs under though.
Your code is working as written, but what is happening is your monitor cannot keep up with the data. Try slowing the baud to 1200, I think it will work fine, if it does it confirms my diagnosis.
It is possible your host machine is not fast enough. Your code is good and it works with an older IDE. What you are seeing is the apparent lack of the receiving machine to keep up with the serial input. If there are other tasks running, can they be turned off as a test, especially any browsers.
I'm having the same issue. It seems to be garbled when I initially open it, however if I close it and then reopen it all seems OK.
As for computer speed or capabilities, I rather doubt that is the issue, I'm using an Intel NUC with an i7 processor and 64GB of RAM running Ubuntu 20.04.
I think there might be two possible causes for this:
The Arduino IDE is not receiving the characters in correct order with the clock signal.
From what I know, The Arduino IDE first stores all the incoming characters in a buffer then prints the output. So there might be some issue storing the character in the incoming buffer.
Thanks @DroneBotWorkshop , you make amazing articles and videos. I love watching them.
Regards.