It was important to do these two verses together. Read the entire chapter (the entire book of Matthew would be even better!) to understand the context. Jesus always took it up a notch!
Ye have heard that it was said by them of old time, Thou shalt not commit adultery: But I say unto you, That whosoever looketh on a woman to lust after her hath committed adultery with her already in his heart. (Matthew 5:27, 28 KJV)