Miscarriage

Was supposed to be 10 weeks last week on Monday 8/5/19 based off my last period which was 5/27/19. Sadly the sac remained empty and kept getting smaller. Had spotting on 8/1/19 but only at the wipe after I peed then again on 8/5/19 but also very light and at the wipe. Went in for an ultra sound on Tuesday 8/6/19 and they said I was showing as 5 weeks + a few days. Still a sac but no embryo. Anyone know what the cause of this might be? I have not bled since then but the doctor said I’m slowly having a miscarriage. What did I do wrong?