Fixed a case where files would be overwritten