Bug Fix: was updating stream position on the wrong stream during write