working write file