If that happen, other investors that bet for the opposite cause of your investment would be the one that gained that money, and you will still able to keep that stocks to collect dividend as long as you don't sell it.
(this circumtances won't happen if the reason you lost the money is the firm going into bankruptcy)