What if? Hasn't happened but asking for possible concern.

If I get pregnant from a friends with benefits, and he didnt want a child to begin with, is it ok to keep the pregnancy secret and break it off with him?