Allowing only gmail.com accounts to register

I want to allow registrations only with gmail.com and hotmail.com email accounts, to reduce spam.

So, I added this piece of coding in my elgg/actions/register.php file:

list($un, $isp) =explode("@", $password);

$gmail="gmail.com";

$hotmail="hotmail.com";

if ((strcmp($isp,$gmail) != 0) && (strcmp($isp,$hotmail) != 0)) {

throw new RegistrationException(elgg_echo('RegistrationException:EmailMismatch'));

}

yet, when I log in with my testing account, it still throws me the exception...

what am I doing wrong?