Code snippets are always hard to interpret correctly.
You don't show where counter is declared, or the contents of your version array, or show what your batch file does to the progam's data...
The usual way to initialise variables is in the main form's OnCreate handler, whether counter is initialised directly with a constant such as zero, or whether you initialise it by reading a value from a file or database.
BTW your file handling will fall over if there is an error - always possible with files - and may make your program crash.