withSink function

Execute an expression while redirecting output to a file