Regarding the tee operator: it's a solved problem, you have ot import it from itertools[0], which should be where any experienced python programmer would strt.
[0] https://docs.python.org/2/library/itertools.html#itertools.t...
s = tee(stdout, myOutFile)