Ensure there is a newline after script blocks

When there is a user-supplied script that doesn't end in a
newline, the template appends "endscript" to the block rather
than on a newline by itself.