Code for write file