Drinking hot tap water from tankless?

I'm sure this is a dumb question, but hear me out and dont downvote me into oblivion:

I've always been told that you shouldn't drink or cook with hot tap water. the reason given that it could be contaminated with chemicals or bacteria from the tank. I now have a tankless water heater. Does that mean I can consume the hot tap water? Where am I going wrong with this thought?