Dumping TTree variables to a file

What would be the fastest and easiest way of dumping some variables from a TTree to a plain text file?
I am thinking in something similar to TTree::Scan(), but within an output file.

Thanks in advance…

root> tree.SetScanField(0); // no page break if Scan is redirected root > tree.Scan(....); >scan.log