Fixed a bug that would cause a directory to be made of the filename.

A new directory was being made with the same name as the filename and then the file was being copied to that directory. This would break file rotation since it could not remove the directory with os.remove().