UTI in early pregnancy

I got diagnosed with a UTI about 2 weeks ago when I found out I was pregnant. I took the medication and the doctor retested my urine last week. It looks as though it’s came back or never went away ... is this really bad ? Am I going to loose the baby ? I’m almost 6 weeks along ...