Fixed incorrect read in session_message::write()