title: Reading a text file line by line and storing it in an array using batch script
body: <p>I want to read a text file and store each line in an array. When I used the code below, <code>"echo %i%"</code> is printing <code>0</code> every time and only <code>array[0]</code> value is getting assigned. But in <code>"set n=%i%"</code>,<code>n</code> value is assigned as the last incremented I value.Also <code>"@echo !array[%%i]!"</code> is printing like <code>!array[0]!</code> instead of printing the value. Is there any syntax error in the code?</p>
  
  <pre><code>set /A i=0
  
  for /F %%a in (C:\Users\Admin\Documents\url.txt) do (
  
  set /A i+=1
  
  echo %i%
  
  set array[%i%]=%%a
  
  )
  
  set n=%i%
  
  for /L %%i in (0,1,%n%) do @echo !array[%%i]!
  </code></pre>