removed useless variable expansion
Rewrite condition
Replace while loop by until loop

In the context, until is semanticaly more correct than while.
Could be discussed of course :)
Added new grep option