Java(script) save variable outside of program : I am writing a simple iterator script in a third party program:

    var 1 = 1.
    function run(){
     output1 = i;
     i = i + 1
    }

This function is run for every record. But the program works with batches of 25 records. So for 100 records it outputs 4 times 1 to 25. I have access to the java libs. It is a linux server. Can I put i in some kind of global java variable or memory, so i can live outside of my program? I tried reading and writing i to a text file. This works but is to slow giving me some empty's, ones and two's. Making the program wait would be my last option (how can I do that?

I have no other easy to add these numbers. I am limited by the program.