Fixed an accidental file-overwriting-directory situation