changed from append to write so it will overwrite the file if it already exists