You don't need to pipe the log to grep with cat since grep will take a file input as a second parameter.
grep "$i" /var/log/secure | ...
Thanks for the great write up.
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.