fix: open writeStream before write
fix add error handlers for read and write streams
Merge pull request #39 from coderaiser/patch-1

fix: open writeStream before write