In a large bowl, mix 1 cup of the flour, sugar, salt, and yeast. Stir in the warm milk and softened margarine until combined. Then, add the sourdough starter and mix well.
Gradually add the remaining 3 ¾ cups of flour, mixing until the dough comes together. Depending on your kitchen's humidity, you might need a little more flour.
Turn the dough out onto a floured surface. Knead it for 8 to 10 minutes, until it’s smooth and elastic. You’ll know it’s ready when it lightly springs back when you press it.
Place the dough in a greased bowl, turning it once to grease the surface. Cover it with a kitchen towel and let it rise in a warm spot for about 1 hour, or until it has doubled in volume.
Punch down the dough to release any air, then cover it again and let it rest for 15 minutes.
Divide the dough into 2 equal portions and shape each into a loaf. Place them on a greased baking sheet, leaving space between them. Let them rise again until doubled, about 1 hour.
Preheat your oven to 375°F (190°C). In a small bowl, whisk together the egg and water. Brush the mixture over the tops of the loaves, then sprinkle with chopped onion.
Bake for 30 minutes, or until the tops are golden brown and an instant-read thermometer in the center reads 190°F (88°C). Cool on a wire rack before slicing and serving.