finetune writing to file