Adding lines to CSV file of FTP server without rewriting the file

Hello, everyone. Need help

How do I add lines to CSV files on external FTP server?

Libraries I use:


  if (ftp.connect(FTPserver, user3, pass3)) {
    Serial.println("Connecting to FTP server");
    const byte BUFFER_SIZE = 5;
    char buffer[BUFFER_SIZE + 1];
    String bff ;
    buffer[BUFFER_SIZE] = '\0';
    char data[1000];
    WriteBufferStream stream(data, 1000);

        while (csv.readField(buffer, BUFFER_SIZE))
          bff = bff + buffer;
        bff = bff + ";";
      while (csv.nextField()  );
      bff = "";
    while (csv.nextLine() );
    stream.write(uint8_t('\0'));, stream);

    Serial.println("File ended");

Code I attached does everything except the last bit. I successfully read the file field by field and store it in a data array, data array shows what it supposed to be in a monitor, even the file is created on an FTP server, but the content is empty.

github page of FTP lib states that I can use stream created with StreamBuffer lib, am I using it correctly?

I tried to outsmart the code and substituted, stream);


Serial2.println(data);, Serial3);

by adding a jumper from TX2 to RX3 and it worked, but only stored 1st 40 characters or so (which I assume due to Serial buffer limitations). Doing the same jumper trick but moving the store command 1 loop deeper (every line as oppose to in the end of the file) trying to store every line also works, but it seems to rewrite the line and I always end up with only the last line (Serial2 prints bff instead).

FTP lib states, that the 2nd argument supposed to be a stream and I have little to no experience with it

Please, help, keep starring at the monitor with no clue

partially solved. Write example is for adding data to stream, read is for retrieving data from it

still would like some help on adding lines

or - better - how to get 30000 character stream