modified slightly to ensure that if a directory is passed as the path, file will be generated there.
fixed style
Merge pull request #1 from wiggzz/master

genfile() generates a file name only when the path given is a directory or the path isn't specified.