`w.write_line("}")` seems more appropriate here.