serial data write to text using processing random newlines

Arduino Code

void loop() {

  for (Bcol = 0; Bcol < 15; Bcol++) //loop through cols
      {
         testcont = Bcol;
         SPI.transfer(testcont);
         
         digitalWrite(latchPin, HIGH); //send latch
         digitalWrite(latchPin, LOW);
         delayMicroseconds(100);

         analogReadResolution(10);
         //analogRead(analogPin1);
         val1 = analogRead(analogPin1);
         Serial.println(val1);
         //Serial.print("\n");
         Serial.flush();
         

      }

Processing Code

void draw() {
    
    if (mySerial.available() > 0 ) {
      mySerial.bufferUntil('\n');
         String value = mySerial.readString();
         value = trim(value);
         if ( value != null ) {
              output1.println( value );
              //output1.print("\n");
              output1.flush();
              
         }
    }
}

the output text file looks like

591.00
574.00
583.00
606.00
613.00
697.0
0
640.00
613.0
0
603.00
688.0
0
588.00
672.0
0
618.00
618.
00
613.00
601.00
597.00
581.00
646.00
592.00
606.00

Any Idea why there are random newlines?? The data coming from arduino is fine as i checked it in serial monitor Tried doing trim, not doing trim, putting in flush, not doing flush, lowering baudrate, doing mySerial.bufferUntil(’\n’);
any ideas?

Try this for the processing part

import processing.serial.*;

Serial mySerial;
int lf = 10;
boolean newVal = false;
String rStr;

void setup() {
  printArray(Serial.list());
  mySerial = new Serial( this, Serial.list()[0], 115200 );
  mySerial.bufferUntil(lf);
}
void draw() {
  if (newVal) {
    print(rStr);  // cr lf still in string
    newVal = false;
  }
}
void serialEvent(Serial p) {
  rStr = p.readString();
  if ( rStr != null ) {
    if (rStr.length() > 2) {
      newVal=true;
    }
  }
}

!!! IT WORKED Thank you
Very much appreciated!!!