Bug 1900: edit_template inserts extra new line

New condition for adding elements in a file was added.