If you don't want to remove lines from your file then do it via global variable (counter), like with usual var, but th changes of variable will be applied to all threads, so what you need.
First of all you should initialize your counter by 0 in the project, but to don't initialize it each time...