tee function

Duplicate a data stream and write it to file