writing the output in file