Why does this script not work?:
The purpose is to display individually every "word" in a file. %file DOES exist on my system, and if you test it it should be an existent file on yours.


//var %file = "C:\temp\hi.txt", %i = 1 | while (%i <= $lines(%file)) { tokenize 32 $read(%file, %i) | while ($1 != $null) { echo - $1 | tokenize $2- } | inc %i }

Contents of C:\temp\hi.txt:
this is a test
and some more

Expected Output:
- this
- is
- a
- test
- and
- some
- more

Actual Output:
- this


Mirc help says while nesting IS supported.

However, If I just take the above script and seperate it out line by line, then it does work:
alias echofile {
var %file = "C:\temp\hi.txt"
var %i = 1
while (%i <= $lines(%file)) {
tokenize 32 $read(%file, %i)
while ($1 != $null) {
echo - $1
tokenize $2-
}
inc %i
}
}

Why does not the one-liner version of the above script work correctly?

Another question:
If I want to iterate through a tokenized list, is there no other way except pushback (e.g., like in bash scripts)
In other words, how can I get this to work:

alias echowords {
var %i = 1
while (%i <= $0) {
echo Word %i is: $%i
inc %i
}
}
What should I replace "$%i" with to return the i'th token of $1- ??
The only other way I know of is this:
alias echowords {
var %i = 1
while ($1 != $null) {
echo word %i is: $1
tokenize 32 $2-
inc %i
}
}

But I consider this 'pushback' method undesirable... can it be avoided?