Can't export vertex colors in edit mode
Set it to Object mode before you begin:  

bpy.ops.object.mode_set(mode='OBJECT')


...
I tried running your code.  It doesn't do anything over here in any mode.  

import bpy
def export(filepath):
  obj = bpy.context.object
  mesh = bpy.data.objects[obj.name]
  obj.data.calc_normals_split()

  with open(filepath, 'w') as f:
    for poly in obj.data.polygons:
      for loop_index in poly.loop_indices:
        loop = poly.loop_indices[loop_index]
        vert = mesh.data.vertices[loop]

        f.write("v %.4f %.4f %.4f\n" % vert.co[:])
        f.write("c %i " % (mesh.data.vertex_colors.active.data[loop_index].color[0] * 255))
        f.write("%i " % (mesh.data.vertex_colors.active.data[loop_index].color[1] * 255))
        f.write("%i\n" % (mesh.data.vertex_colors.active.data[loop_index].color[2] * 255))
        f.write("\n")


It throws: IndexError: range object index out of range
I don't think mesh.data.vertices is pointing to the right number though.