Optimized code.
Back to .NET4, the Mono version I'm using apparently does not support .NET4.5
added another way for writing stream and console at once;