make sure write is set before using it