caching outputstream seems ok. detect EOFException