Bacteria, which cause infections, can themselves be infected by viruses called bacteriophages. Just as not all bacteria are harmful to humans, not all viruses are harmful to bacteria, and some can even benefit them. Can bacteria distinguish good and bad viruses? An interdisciplinary team of scientists at the Institute of Science and Technology Austria (IST Austria) studied how infections with potentially beneficial viruses play out in bacteria that carry a certain type of anti-viral immune mechanism called restriction-modification (RM). They show that population-level interactions between viruses and bacteria make the infection proceed in a way that compensates for the inherent disadvantage of individual cells and allows immune bacteria to acquire many more beneficial viruses in the long term. This is the finding of a study published in Nature Ecology & Evolution. The study was carried out by Maros Pleska, a PhD student and Moritz Lang a postdoc in the group of Celin Guet at IST Austria, as well as collaborators Dominik Refardt at Zurich University of Applied Sciences and Bruce Levin at Emory University.