My code accepts one argument, which is the input file. To output, redirect STDOUT to a file by using a > like so:

Code:
./inv.sh inputfile > outputfile
Note that if outputfile exists, you'll want to use >> so its contents are not overwritten.