writeandexecute: check for no directory in file argument

Only check whether the directory exist if the file argument
has a directory component. Prevents a error in that case.
Merge pull request #14 from JanSchulz/writeandexecute_fix

writeandexecute: check for no directory in file argument