Replaced echo stream by writer to avoid double endcoding