Finish WriteStream implementation (still buggy)