I don't understand your issue. Also, you should only read the file once if the map file is not expected to change mid-game. You should look how mapchooser does it and use something more similar to that because your current method is way overkill (and might be the cause of your problem).