error with find

for FNAME in `find . -type f -exec grep -il unixs317 {} \;`; do C=`grep -c unixs317 ${FNAME}`; echo "${C}:${FNAME}" >> output.txt; done

When I run this command and a directory is empty it is returning an error and just does nothing more.

How can I continue with my search even when it find no matches and a directory is empty

The command sequence is very hard to follow.
What is the exact error you see?
What is the script meant to do?

Are you trying to find all files in the current directory tree which contain the string "unixs317" and output the count of "unixs317" in each named file to output.txt ?

Agree with methyl and use code tags so that the posted commands are easy to follow. Here is an alternative way of writing your command line

find . -type f -exec grep -il unixs317 {} \; | while read FNAME; do
   C=`grep -c unixs317 ${FNAME}`
   echo "${C}:${FNAME}" >> output.txt
done

why won't this do what he wants:

find . -type f -exec grep -ic unix317 /dev/null {} \; | grep -v /dev/null >> output.txt

It looks like all he wants is a count and a file name....