Machine-generated text detection prevents language model collapse