Changing written files to overwrite instead of append