Please
UseCodeTags next time. It makes it easier to read your code.
It appears that this code replaces lines of a file that contain a specific sub
string. Because modifying files on the fly is very tricky it uses an intermediate temporary file to write to first, which then overwrites the original file.