Live edit works, addon doesn't. [No errors]

Hi everyone!

I wrote a simple script that adds a UV map to each selected object. It works great, no problems. And in order to avoid having to load the text file each time I need it I made it into an addon. The button shows up and I eliminated all errors. However, like this it only adds the UV map to the active object and ignores the rest.
Edit: It adds a UV map to one random object. Selected or active doesn’t matter.

Why does it work in the identical live edit code but not in the addon?

ops = bpy.ops
context = bpy.context
#if bpy.context.selected_objects != []: #### THIS GIVES AN ERROR IN ADDON ONLY
# so instead:
if len(bpy.context.selected_objects) > 0:
    for obj in bpy.context.selected_objects:
        if obj.type == 'MESH':
   = obj
            return {'FINISHED'}

And full disclosure: I’m at beginner level in python. I took a lot from this How do I iterate through objects in a Scene? and made the addon by looking and copying some lines from the Amaranth Toolset.

Thank you in advance!