Add comments

Add comments to explain what things do, and an option to print to file instead of echoing.