Vl6180x and Uno - Processing3 code?

Good morning
i am wondering if anyone could help me with this little code, or point me in the direction on why it is not working.

singular function: Reading range from a lidar, and save it into a text document, to be my Y variable in a pointcloud mesh.

i am trying to use processing to do the processing of the data comming from the serial. and i am able to read the data from the Vl6180x sensor in Processing, so it it receiving data.
i have gotten it to create the textfile, however it is not writing anything in it.

i have checked the forums around on the web, however codes that is working for others, still won’t write.

Uno code

#include <Wire.h>
#include "Adafruit_VL6180X.h"

Adafruit_VL6180X vl = Adafruit_VL6180X();

void setup() {
  Serial.begin(115200);

  // wait for serial port to open on native usb devices
  while (!Serial) {
    delay(1);
  }
  
  Serial.println("Adafruit VL6180x test!");
  if (! vl.begin()) {
    Serial.println("Failed to find sensor");
    while (1);
  }
  Serial.println("Sensor found!");
}

void loop() {
  
  uint8_t range = vl.readRange();
  uint8_t status = vl.readRangeStatus();

  if (status == VL6180X_ERROR_NONE) {
    Serial.print("Range: "); Serial.println(range);
  }


  delay(2000);
}

Processing code

import processing.serial.*;
Serial myPort;  // Create object from Serial class
String val;     // Data received from the serial port
PrintWriter output;


void setup() //konfigurasjonen i programmet
{
//Open port 1, 115200
  String portName = Serial.list()[1]; //change the 0 to a 1 or 2 etc. to match your port
  myPort = new Serial(this, portName, 115200);
   // Create a new file in the sketch directory
  output = createWriter("data2.txt");
}
void draw() //Loopen i programmet
{
  
  if ( myPort.available() > 0) 
  {  // If data is available,
  val = myPort.readStringUntil('\n');         // read it and store it in val
     output.println(val); // Write the data to the textfile
  } 
println(val); //console print to verify information
}


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

~~Are you sure that the serial port in the Processing code is right? I usually specify the port name once that I know it. ~~
I tested the Processing code with my Uno and a short test program:

***** Karma for code tags in first post. Most new members have to be asked to read the guidelines.

I misread the OP. So sorry for wasting time.

presumably your "Uno" code demonstrates that you can read data from the VL6180x which you're displaying on the serial monitor.

it looks like your "Processing" code is attempting to create and write (i.e. output.println()) to the creatde file.

why doesn't your "processing" code read the VL6180x as your Uno code does, but instead of displaying it to the serial monitor, why not "output.println()" it to the file created? i don't understand why you're code creates a new serial interface