Add output file option and fix formatting.