Saving serial data to a text file

Hello!

The formatting of the saved text is a bit garbled.

Processing code:

void draw() {
  background(50);
  textFont(t, 20);
  fill(255);

  readSerial();
  drawBenchA();
}


void drawBenchA() {
  
}

void readSerial() {
  if (mySerial.available ()>0 ) {
    String myString = mySerial.readStringUntil('\n');
    if (myString!=null) {
      for (int i = 0; i<myString.length (); i++) {
        Str1 [i] = myString.charAt(i);
      }
    }
    mySerial.clear();
  }
  
  for (int i = 0; i < 15; i++)
  {
    output.print(Str1[i]);
  }
  
  textFont(t, 16);
  fill(255);
}


void keyPressed() {
  output.flush();  // Writes the remaining data to the file
  output.close();  // Finishes the file
  exit();  // Stops the program
}

Text file:

        Start
        Start
        Start
        Start
        Start
        Start
        Start
        Start
        Start
        Start
        Start
        Start
        Start
        Start
        Start
        Start
        Start
        Start
        Start
        Start
        Start
        Start
        Start
        Start
        Start
        Start
        Start
        Start
        Bench A
      velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-Seconds
27546-Seconds
27546------

27546------

27546------

27546------

27546------

27546------

27546------

27546------

27546------

27546------

27546------

27546------

How it should appear:

Start
Bench A
Envelope 127546-2
5 Seconds
----------------------------

I think this can be fixed with serialEvent, but not sure how.

I think this can be fixed with serialEvent, but not sure how.

Have you looked at the documentation, on the Processing web site, for the serialEvent() method?

Have you looked at the documentation for the Serial::bufferUntil() method?

Have you considered posting ALL of your code?