Added some more try catch functionality to prevent cryptostream write errors