Implement saving output to file