Minor civs are not listed because you bounded your loop to MAX_MAJOR_CIVS-1, this is the only reason. Minor civs start after that.

Even if minor civs do not have a leader, they can still be enumerated the same way and the GetName function works properly for them (it returns the CS name rather than the leader's name). So, as I said, use MAX_CIV_PLAYERS - 1
Now for the crash, it's because you queried the player name before you verified IsEverAlive: if you use functions on a civ that was never present in the game (IsEverAlive returns false), it crashes. So just put that print call after the IsEverAlive test. It also provides another explanation for the minor civs not being displayed: your code crashes before that point.
So it's not like your code is stuck in an inifinte loop, it's just civ5 becoming crazy. Also you do not have to put a "return" instruction if you do not need the returned value. Besides I don't know what happens if you use return outside of a function. Nothing I guess.
Also, I suggest you put the "print" calls on their own lines, or use ";" to separate them from the previous statement. You're indeed supposed to put a line break or a ";" between two statements. And I am surprised LUA managed to interpret your code like that but I guess you will get a bad surprise someday if you keep that habit.
Finally, one advice: I suggest you use the hungarian notation (adding a type identifier prefix on names: iCity, iPlayer, pPlayer, bFlag, etc - i for integer, p for pointer/structure, b for boolean). Unfortunately I usually work with strongly typed languages through a good IDE and that makes the hungarian notation useless, but on a dynamic language like LUA it's golden. I wish I had remembered that before IGE reached thousands of lines of code.