You don't say which part of this is giving you trouble - i.e. is it the
generation of the random number for the first run, or the storage of this random
number in a file for use by the next run, or working out whether it is the first
run of the program (random number wanted) or a subsequent run (non-random number
wanted)? Please expand on where your problem lies.
To hold the value between runs, you will need a file.
To work out if this is the first run of the program, probably the best way would
be to check whether the above file exists yet. If it doesn't, then it can be
assumed that this is the first run. If it does, simply read the number from the
last run, add 1 and write it back.