attack of the clones

I’m trying to write exporter and i need to triangulate a mesh, but my script not working properly:

#!BPY

"""
Name: 'Bin'
Blender: 246
Group: 'Export'
Tooltip: '....'
"""

import Blender
from Blender import *
import bpy
import BPyMessages

import struct
from struct import pack

def export_mesh(filename):
	print 'object',[o.name for o in Object.Get()]
	print 'meshes',[m.name for m in Mesh.Get()]

	editmode = Window.EditMode()
	if editmode: Window.EditMode(0)

	scn = bpy.data.scenes.active
	object = scn.objects.active
	if not object:
		BPyMessages.Error_NoActive()
		return
	if object.getType() != 'Mesh':
		BPyMessages.Error_NoMeshSelected()
		return
	
	temp_name = '~tmp-mesh'
	temp_mesh = None
	try:
		temp_mesh = Mesh.Get(temp_name)
	except:
		temp_mesh = Mesh.New(temp_name)

	temp_mesh.getFromObject(object)
	temp_ob = scn.objects.new(temp_mesh)
	
	temp_mesh.quadToTriangle(0)
	
	print 'verts=',len(temp_mesh.verts),', faces=',len(temp_mesh.faces)

	scn.objects.unlink(temp_ob)
	
	print 'objects',[o.name for o in Object.Get()]
	print 'meshes',[m.name for m in Mesh.Get()]
	

              # ...........
	if editmode: Window.EditMode(1)
	#file.close()

print '
--==--'
Window.FileSelector(export_mesh, 'Export mesh', sys.makename(ext='.bin'))

every time of exporting a mesh number of temporary object is growing :(. Mesh list in panel “Links and Materials” contain temporary mesh name as well. Saving and opening twice make it dissapear.

Please, help