those cups are a bit small for raising fruitflies. Like you say they will all escape when you open it.
I use sweet jars or tall ice cream tubs to raise mine with a little cup filled with medium in them.
I would recommend that once you get your next cup, try and transfer as many flies to your...