implemented output to file