writing output to a file