Use -r test consistently rather than -f

Implicitly check whether file exists and is legible
Explicitly check extension of .d files
Not sure why I ever set TTY