Add support for writing output to file