Staying for the baby.....

Daily we see posts from women who are pregnant but their SO/DH/BF ended the relationship and they're alone during their pregnancy. These men are always spoken of negatively, called deadbeats, etc. My question is, should these men remain in the relationship solely because the woman is pregnant?  Many times these situations arise because he wants to leave the relationship or plans to leave the relationship, but it's discovered that hes gotten her pregnant before he can make the break. Should he stay despite knowing he doesn't love this woman anymore?  If so, how long should he stay?  Does he just stay for the pregnancy and birth or does he put aside the fact that he doesn't love his child's mother and just stay with her indefinitely. If he doesn't love her, but she's pregnant, when is it acceptable for him to leave?