.htaccess redirect from olddomain to newdomain

A friend of mine wanted to redirect an old domain to a new doman, he made a simple 301 redirect but as the server physical ip was the same he falled into an redirect loop between domains.

What he needed to fix that is an if condition in the rewrite rule, I made this snipplet for him.

RewriteBase /
RewriteCond %{HTTP_HOST} !newdomain.com$ [NC]
RewriteRule ^(.*)$ http://newdomain.com/$1 [L,R=301]