Unlike lytic phages, temperate phages maintain long-term association with their bacterial host through lysogeny. In this context mutual beneficial interactions can evolve that support efficient co-reproduction. Temperate phages are essentially large DNA insertions, which disrupt the bacterial chromosome and pose a significant burden on the cell. In this work we identified a fascinating example of a temperate phage that aids its bacterial host by serving as a regulatory switch. In this case a prophage inserted within a bacterial functional gene, which was shown to promote Listeria monocytogenes mammalian infection, was found to undergo precise genome excision that leads to complete restoration of the disrupted gene, while avoiding lytic production. Using this strategy the bacteria and the phage maintain an interaction that minimizes genome disruption and gene loss.