error check on writing .d file

For issue #492. I'm not sure if this is the right fix though.

Fatal() seems wrong because the busted .d will remain. Will an error code from -t try to remove compiler outputs? I think it won't, but I'm not entirely sure.