You can find a good tutorial for writing loops
here and
here.
As for what you want to do, mIRC has some trouble reading a series of spaces, so I'm not quite sure just how well, this would work. However, if you're talking about reading a certain number of characters from each line only and removing all the other characters on that line, you can use this:
alias altered {
if ($exists($2) != $true) { return }
var %i = 0
while (%i <= $lines($2)) {
write $+(-l,%i) $2 $left($read($2,%i),-N)
inc %i
}
}
Replace
N (in
$left($read($2,%i),-N)) with the number of spaces that you wish to remove.