Code: Select all
for /f "delims=" %%i in (some_file.txt) do (
echo %%i
)
Then each line of the file is echoed out. OK, so far so good. But if I make this ever so small change...
Code: Select all
for /f "delims=" %%i in (some_file.txt) do (
set "line=%%i"
echo %line%
)
Then it doesn't at all behave like I would expect. I would expect that at each iteration of the loop, the variable "line" would be set to the current line of text, then echo would of course echo that line. But what actually happens is that the echo statement is always ever printing the *last* line of the file, over and over, for every iteration. Why...?! This behavior doesn't make any sense to me. Can someone help me out?