only write out valid samples