Add support for writing to output file in CLI