Basic Shell Scripting

Hi Fellow Developers,
I recently started learning about shell scripting and was trying to solve question 3 of exercises at the end of this page : https://missing.csail.mit.edu/2020/shell-tools/ .
I wrote the following script : https://justpaste.it/5gr98
In this the while loop is executing properly(found it by echoing text to the terminal), but the lines after while loop do not execute. Can anyone please help me out with the code.

im not a shell pro but ill try

your while loop is missing ;

is output.txt 2 supposed to be output.txt $2 ?

with contitionals, you have to leave a space after ‘[[’ and before ‘]]’ or it wont work (i think)

helpful link

Hey @alkapwn3d
There is a space between [[ and before ]], it may not be apparent in code pasted here.
By output.txt 2> error.txt, i want to redirect the output stream to output.txt file and error stream to error.txt file. I even tried removing error.txt from code and still it doesn’t work.
Thanks for the cheatsheet though.