Donitz, commander of the U-boat fleet had two precepts:
1. Attack at night on the surface using the near invisibility of the low profile of the boat and its speed on the surface which was faster than a transport. The type VII was developed specifically for this purpose.
2. He did not recognize the Hague Convention which said that civilian shipping had to be forewarned and the crew allowed to get in the life boats before the sub attacked. In his view, the ship sending a report or SOS prior to the attack was an Allied intelligence source and therefore was fair game for a surprise attack.
So, yes they all got what they deserved thanks to the convoy system and the development of cm wave radar and sonar. Thankfully, Donitz was slow on the uptake when it came to technology and he was an unmitigated disaster when he was promoted to CINC of the German Fleet. He spent 10 years in Spandau prison as a war criminal.