Write to files through tmp file;