Added check if the new IP matches the old IP then it will not overwrite the file.

Using new function to write text to file.
Removed debug echo from script.