add logging to Writer, fix offset issue