Change print to write file