This is just bad, bad code design. You should seriously consider a rework of your game structure.
It's pretty pointless to store anything in a "i dont know exactly how many items i need to store" matter.
Sure, the example code above will work, even if you'd need a variable which has the number of elements to read, also stored in your file.
If you really want to continue with your approach, check out the previously mentioned JSON format, even XML will do.
If you continue in that hackish way, you'll be very frustraed at some point and you'll end up throwing your project away.