You had INI file both in Program Files folder (where you did not have write permissions). WinSCP was reading the configuration from there. But when writing, the old versions (you were using before upgrade) were writing to your user profile folder (due to Windows feature called file virtualization). This was prevented since 5.0.1 as it caused lots of confusion:
But the change caused troubles as well, as people had (unwrittable) INI files in program files, what made WinSCP show error now. So there was another change in 5.2 that made WinSCP fall back to user profile:
That's shortly why 5.2.3 works for you, 5.1.6 does not and 4.x did :)
I hope it makes sense.