writing output to file