Remove non-UTF8 character from html code, and insert missing endif block