Added writeFile op and logging for stream exceptions