title: Counting in a FOR loop using Windows Batch script
body: <p>Can anyone explain this?  I am able to count in a loop using the Windows command prompt, using this method:</p>
  
  <pre><code>SET /A XCOUNT=0
  :loop
  SET /A XCOUNT+=1
  echo %XCOUNT%
  IF "%XCOUNT%" == "4" (
    GOTO end
  ) ELSE (
    GOTO loop
  )
  :end
  </code></pre>
  
  <p>But this method does not work (it prints out "1" for each line in the file).  It acts like the variable is out of scope:</p>
  
  <pre><code>SET /A COUNT=1
  FOR /F "tokens=*" %%A IN (config.properties) DO (
    SET /A COUNT+=1
    ECHO %COUNT%
  )
  </code></pre>