How to save terminal command line output to a file