Serial.print() prints out of order and with repeats

I have been having a problem with Serial.print() printing data out of order, with extra line breaks, and repeating data. Here is the simplest example:

int x = 0;
void setup() {
  Serial.begin(9600);
}
void loop() {
  Serial.println(x);
  x++;
}

Here is what the Serial Monitor Displays

1
2
3
4

1
2
3
4
5
6
7
8
5
6
7
8
9
10
11
12

9
10
11
12
13
14
15
16
13

I am an Engineering and Robotics Teacher using the Web Editor IDE. My students have Chromebooks, so I have to use the Web Editor. For the past few years the Serial.print() commands worked exactly as expected. I first noticed this problem last spring. I am using an Arduino Uno R3 that is a few years old (purchased in 2021).
Here are things I have tried and have not worked:
-Switching computers
-Switching Arduino Unos (all 2+years old)
-Using the Board Manager in Arduino IDE to update the board
-Adding delays before and after each line
-Adding a Serial.flush() before and then after the print
-Tried uploading sample code from the Arduino Serial.print() documentation (similar problems with output)
-The value stored in the variable appears to be updating correctly (it increases the brightness of an LED predictably.

Things that have resolved the problems.
-The Arduino Nano 33 IoT board completes the Serial Print without problems. (I own 80 starter kits with Arduino Rev 3 boards and I would like to not have to replace them all)
-The problem does not occur in the IDE, just the Web Editor. (My students use the web editor with their Chromebooks)

I am at my wits end, hopefully someone has seem and solved this problem. Thanks in advance.

Do you experience the problem regardless of where you are located (in terms of using a different internet connection)?
Is there any difference between using wifi and wired network connection?

Hi,

Your code works okay here, have you changed USB cables?

Tom... :grinning: :+1: :coffee: :australia:

Since the UNO works ok with the IDE, I wouldn't think the UNO or the USB cable would be the problem.
You mentioned having the problem on a chromebook, do you get the same problem on a Windows computer?
Seems more likely to be an internet or website problem, except that you stated the Nano 33 IoT does not have the problem. Maybe some oddity with the USB driver used for the UNO.

Thanks everyone! Great suggestions. I am using a Windows PC and the problem persists. I have tried changing USB cables and have worked on hardwired and wifi internet connections. My current theory is that everything is working fine, it is just the displayed values on the Serial monitor that are problematic. I will test the real code on the robot this week and will let you all know if it works. I would still love to figure out the Web Editor Serial Monitor problem so that I can problem solve with my students if they encounter the same issues.