In the context of checking for duplicate email addresses in a file, why is using strpos() with file_get_contents() considered a better approach than array_search() with file() in PHP?

When checking for duplicate email addresses in a file, using strpos() with file_get_contents() is considered a better approach than array_search() with file() because file_get_contents() reads the entire file as a string, allowing for easier manipulation and searching using strpos(). On the other hand, file() reads the file into an array line by line, making it less efficient for searching within the content.

$file = 'emails.txt';
$emails = file_get_contents($file);
$emailList = explode("\n", $emails);

$emailToCheck = 'example@email.com';

if(strpos($emails, $emailToCheck) !== false){
    echo "Duplicate email found!";
} else {
    echo "No duplicate email found.";
}