Tips for writing quines
Take advantage of string formatting
One of the easiest ways to create a quine is to define a string, then put the string inside itself with string formatting.

s='s=%r;print s%%s';print s%s



So in this example Python quine, we declare a string with the first part equal to whatever is before the string s=, then we allow for the string to be inserted with formatting with %r, and finally we put what comes after the string to print and format it. The trailing newline is because print prints a trailing newline.
So the template is really this, in Python:
&lt;A&gt;'&lt;A&gt;%r&lt;B&gt;'&lt;B&gt;

To expand the existing quine with more code:
&lt;more A&gt;s='&lt;more A&gt;s=%r;print s%%s&lt;more B&gt;';print s%s&lt;more B&gt;