diff --git a/anki/collection.py b/anki/collection.py
index e0c1497e4..69860744e 100644
--- a/anki/collection.py
+++ b/anki/collection.py
@@ -492,8 +492,8 @@ where c.nid = n.id and c.id in %s group by nid""" % ids2str(cids)):
fields['c%d' % (data[4]+1)] = "1"
# render q & a
d = dict(id=data[0])
- qfmt = qfmt or template['qfmt']
- afmt = afmt or template['afmt']
+ qfmt = (qfmt or template['qfmt']).replace("}}\n", "}}
")
+ afmt = (afmt or template['afmt']).replace("}}\n", "}}
")
for (type, format) in (("q", qfmt), ("a", afmt)):
if type == "q":
format = format.replace("{{cloze:", "{{cq:%d:" % (