grep.sh main function strengthened