PrintWriter output; String words=""; void setup() { size(300,200); output = createWriter(selectOutput("save output file as")); } void draw(){ background(255); fill(0); text(words, 25, 25); } void keyPressed() { // If the return key is pressed, save the String to a file and exit if (key == '\n' ) { output.println(words); output.flush(); output.close(); exit(); } else { // Otherwise, concatenate the String // Each character typed by the user is added to the end of the String variable. words= words + key; } }