write to tmp file