Added file removal, and duplicate file handling.

Handles duplicates by replacing the old file with the new one.