It seems Stefans solution is right - but the reason isn't
Just to understand what happens the right reason: "Operator Precedence"!
The String Concatenator "." has the lowest precedence of all operators. (Especially it's lower than "!=".)
So:
if ($first.<crlf>.$second != "# Adblock Plus preferences".<crlf>."version=4")
is the same as writing:
if ($first.<crlf>. ($second != "# Adblock Plus preferences") .<crlf>."version=4")
And no doubt: this cannot lead to the correct result.
To make it formally correct
(without further change) you would have to write:
if (($first.<crlf>.$second) != ("# Adblock Plus preferences".<crlf>."version=4"))
Of course Stefans solution of
putting <crlf> inside (the) double quotes, and by this not needing concatenation characters (conflicting with !=) looks better:
if ("$first<crlf>$second" != "# Adblock Plus preferences<crlf>version=4")
By the way: I would have coded:
if ( ($first != "# Adblock Plus preferences") || ($second != "version=4") )