First, here is an example of a cleaner way to output, removing the extraneous echo's and redirections:
Code:
var1=cat
var2=dog
>output.txt cat <<-END
this is
multiline output
$var1
$var2
END
You don't need the initial touch command; the redirection takes care of creating the file. Finally, assign $1, $2, etc. to meaningful variable names, and use those instead, to be self-documenting.
Your CN name needs to match the name of the host.