Remove existing file while handling dir (fixes #952)