Merge pull request #408 from marco-langer/feature/ostream_error_handling

Added error checking to ostream writing