Wrong buffer was being written.