The standard method to debug scripts in most Bourne-based shells, like bash is to write set -x at the top of your script. This will make bash more verbose about what's being done/executed, and how arguments are evaluated.
-x Print commands and their arguments as they are executed.
this is useful for either, the interpreter or inside scripts. For example:
$ find "$fileloc" -type f -prune "$filename" -print
+ find /var/adm/logs/morelogs -type f -prune '-name *.user' -print
find: unknown predicate `'-name *.user'
$ find "$fileloc" -type f -prune $filename -print
+ find /var/adm/logs/morelogs -type f -prune -name '*.user' -print
find: `'/var/adm/logs/morelogs': No such file or directory
In the above we can see why find is failing due some single quotes.
To deactivate the feature, just type set +x.