Do you also have obsession with someone whom you loved?

I liked one girl when I studied in high school, we never dated because she didn’t want a relationship with someone who is younger. But we used to text each other for about 7 years with pauses for 3-4 months and even more. Recently I found a new love, we dated for 6 months and broke up, as we understood that we can’t be together. But I am afraid that I can get into another loop. Because both of them always respond to me when I write to them. If you have been in such situation, how did you resolve it?