Replace words with different synonyms and print each combination in a text file

Do you mean to store this as a text file?? I don’t think that’s a good idea.
Instead you can just have them on the screen and save an image of it using save() or saveFrame();




// WILL OVERWRITE OLD IMAGES !!!!!

PrintWriter output;


String s = "Wie froh bin ich, daß ich weg bin! Bester Freund, was ist das Herz des Menschen! Dich zu verlassen, den ich so liebe, von dem ich unzertrennlich war, und froh zu sein!";

void setup() {
  size(1900, 760);
  background(255);
}


void draw() {
  if (random(100)<20)
    s = s.replaceAll("Wie", "Und");
  if (random(100)<20)
    s = s.replaceAll("froh", "ausgelassen");
  if (random(100)<20)
    s = s.replaceAll("bin", "bin");
  if (random(100)<20)
    s = s.replaceAll("ich", "ich");
  if (random(100)<20)
    s = s.replaceAll("daß", "daß");
  if (random(100)<20)
    s = s.replaceAll("weg", "fort");
  if (random(100)<20)
    s = s.replaceAll("Bester", "Erster");
  if (random(100)<20)
    s = s.replaceAll("Freund", "Vertrauter");
  if (random(100)<20)
    s = s.replaceAll("was", "was");
  if (random(100)<20)
    s = s.replaceAll("ist", "befindet");
  if (random(100)<20)
    s = s.replaceAll("das", "das");
  if (random(100)<20)
    s = s.replaceAll("Herz", "Zentrum");
  if (random(100)<20)
    s = s.replaceAll("des", "des");
  if (random(100)<20)
    s = s.replaceAll("Menschen", "Sterblichen");
  if (random(100)<20)
    s = s.replaceAll("verlassen", "entfernen");
  if (random(100)<20)
    s = s.replaceAll("liebe", "anbete");
  if (random(100)<20)
    s = s.replaceAll("unzertrennlich", "vertraut");
  if (random(100)<20)
    s = s.replaceAll("sein", "entstammen");

  output = createWriter("positions.text");

  int x=30;
  int y=200; 
  fill(0); 
  for (String wordIn : s.split(" ")) {
    textSize(random(9, 56)); 
    text (wordIn, x, y); 
    x+=textWidth(wordIn)+6;
    if (wordIn.indexOf("!") > 0) {
      x=30; 
      y+=90;
    }
  }
  //output.print(s);


  //output.flush();
  //output.close();

  stop();
  save("t1.jpg"); 
  noLoop();
}