pose.bones.matrix does not update after frame change via script I write an exporter to retrieve the pose bone matrix for every frame.

The concept looks like this, the code is called from an exporter class via an operation button in the tool shelf:

for action in actions:
    for frame in range(action.frame_range[1]):
        bpy.context.scene.frame_set(frame)
        context.scene.update()

        for poseBone in armature.pose.bones:
            exportMatrix = poseBone.matrix


However, the exported poseBone.matrix values all have the same values from one frame.
I checked in the pyhton console if the values change when i manually change the current frame and they do.

What am I missing to update the pose bone matrix after a frame change?
To summerize, I needed to perform these changes:

for action in bpy.data.actions:
    bpy.context.object.animation_data.action = action # sets active action
    for frame in range(numberOfFrames):
        bpy.context.scene.frame_set(frame)
        bpy.context.scene.update()
        for bone in bpy.context.object.data.bones: # instead of armature.pose.bones
            poseBone = armature.pose.bones[bone.name]