This should fix the error that is checking a directory's existence vs a file's existence before proceeding.