Onan knew the child would not be his, and when he had sex with Tamar, he made sure that she would not get pregnant.