but if the fragmentated ions were to deflect, isnt there a possibility or some possibility some ions wont even reach the detector? hence you cant accurately identify the substance?
That's right. The mass spectrometer can only look at a narrow mass range at any given time.
But to put it into perspective, you would typically work on samples of a few milligrams. That may seem very little, but also remember that 1 mole = 602 000 000 000 000 000 000 000 molecules, so even a small fraction of a mole still has a lot of molecules. The mass spectrometer doesn't need much, and it can work very fast (a few milliseconds), so we can afford to throw most of the sample away.
Imagine this (overly-)simplified scenario.
Suppose the mass spectrometer can only look at a m/z range of 10. We'll look at m/z = 0 -> 10. So we ionize 1 billion molecules and let them fragment/etc. Only a million fragments end up in the range of 0 -> 10, but that's still plenty for the MS detector. So we take this small spectrum, and move on to the next range m/z 10 -> 20. Rinse and repeat, after 10 cycles, we've scanned everything up to m/z=100. Over this time, we've only used 10 billion molecules (~0.00000000000001 moles). Since the MS can work very fast, and it can change the scanning range automatically, we can get a full spectrum in less than a second from a very small amount of sample.
Note that the numbers are mostly made up to convey a point, reality may be a few million times different, but when we're working on the real life scale of moles, millions are insignificantly small in comparison. In reality, we get an efficiency of 1/10,000,000 to 1/100,000,000,000 depending on various circumstances.