As much as I love Python, in this case a '1-liner' using awk and sort or sed, tr, dd etc. would get you there 'faster'.
awk '{print tolower($0)}' domains.txt > whitelist.txt && cat whitelist.txt | sort -o whitelist.txt
That's probably just because the example is kept simple to illustrate Python's terseness, readability, productivity etc.