Board Thread:Questions and Answers/@comment-29905311-20170130083321/@comment-27701762-20170130205246

The line you're thinking of is "friendship.../it's really great, right?/let's quit fighting." That line shows up after you've accepted his offer of mercy. It does not change depending on what previous runs you've done, as the only permanent flag in the games files that is ever changed occurs after you've completed a Genocide run.

Meanwhile, Sans observes more and knows more than just how many times he's killed the protagonist.

But if you are dissatisfied with both explanations, then the only other recourse is that Sans is just guessing, as Flowey does at the end of the True Pacifist route in saying "You've probably heard this a hundred times already." He is just making a presumption that in another timeline you befriended him and hoping that it works.