The 'which IDE?' question hasn't been answered yet, so we don't know what the Serial.flush() is doing.