I've tried to fix the grep -v lines

I've tried to fix the grep -v lines by putting them behind the initial command with a | , and also specifying an output file. Morover, the initial command writes to a _temp file. We could add a line that will delete these temporary files at the end of the script.