Problems with serial.print

Hi, I have this code.

int sum=0;
int b=20;

void setup() {
 Serial.begin(9600); 
  
}


void loop() {
  sum = sum + b;
  
  
  if (sum==800) {
   sum=0; 
  }
  

    Serial.println(sum);
    delay(1000);

  
}

So I upload the code, start the serial monitor and I can see 20, 40, 60 etc.
I disconnect the serial monitor and connect again a couple of seconds later. I expect 240, 260, 280. But I can see it starts from the beginning with 20, 40 .... When I'm online with the serial monitor it works as expected.
Maybe anyone can tell me why?

thx in adavance

Connection resets the Arduino.
You can disable this with a simple mod - check your board's documentation.

I modded the serial dll used for the com port enumeration, so you can use http://arduino.cc/forum/index.php/topic,118440.0.html to avoid disconnections when opening the arduino.

What is the difference between serial.print and serial.printin ?

Println adds a linefeed at the end of the printed text so the next print will be on a new line.

-br

InduinoX:
What is the difference between serial.print and serial.printin ?

Note that it is println (with a lower-case L) and not printin (with a lower-case I).