write data to .txt file

Sorry for my horrible English,
I configured my extractore pattern, and the test shows exactly what I want to extract, but i can't export data.
I read all the tutorials and tried to adapt the examples to my needs but I can't do it in any way.
These are my pattern:
Scheda Azienda~@NOME@~"
with flag save in session variable
and the output is :
0 STUDIO XXXX XXXX" class="_lms _noc" href="http://www.xyvz.it

and i try with this script

// Output a message to the log so we know that we'll be writing the text out to a file.
session.log( "Writing data to a file." );
// Create a FileWriter object that we'll use to write out the text.
out = new FileWriter( "form_submitted_text.txt" );
// Write out the text.
out.write( session.getVariable( "NOME" ) );
// Close the file.
out.close();

Can sameone help write this script correctly? I've tried all mode but i'm not developer

P.S.
the script doesn't work because evry time overwrite the previous data, but i want it write the output in a new line

thank evrybody help me

The problem is where you

The problem is where you define the file writer:

out = new FileWriter(outputFile, true);

Where you pass in that "true" indicates append to the file instead of overwrite. If you add that I think you're good.