Trying to make automatic, sequential screenshots using CameraActor

Hi. I’m trying to make some screenshots using CameraActor and Python code. Everything is running fine, without any error but only last screenshot saves. Any ideas?
This is code:

import unreal

# Define camera settings
camera_location = unreal.Vector(100, -100, 150)  # (X, Y, Z) in cm

# Spawn CameraActor in the scene
world = unreal.get_editor_subsystem(unreal.UnrealEditorSubsystem).get_game_world()
camera = unreal.get_editor_subsystem(unreal.EditorActorSubsystem).spawn_actor_from_class(
    unreal.CameraActor, camera_location
)

# Ensure the camera is selected
unreal.get_editor_subsystem(unreal.EditorActorSubsystem).set_selected_level_actors([camera])

# Get screenshot directory
screenshot_dir = unreal.SystemLibrary.get_project_directory() + "Screenshots/"
i=0
# Iterate through rotations and capture images
for rotation in range(0, 361,50):
    # Set camera rotation
    camera.teleport(camera_location,unreal.Rotator(0,rotation,0))

    # Define screenshot name
    screenshot_path = f"{screenshot_dir}Room_Wall_{i+1}.png"
    # Take a high-resolution screenshot
    unreal.AutomationLibrary.take_high_res_screenshot(1920, 1080, screenshot_path, camera)

    # Print status
    unreal.log(f"Screenshot {i+1} saved at: {screenshot_path}")
    i+=1

And this is log from UE:

LogActorFactory: Actor Factory attempting to spawn Class /Script/Engine.CameraActor
LogActorFactory: Actor Factory attempting to spawn Class /Script/Engine.CameraActor
LogActorFactory: Actor Factory spawned Class /Script/Engine.CameraActor as actor: CameraActor /Game/model.model:PersistentLevel.CameraActor_0
LogActorFactory: Actor Factory spawned Class /Script/Engine.CameraActor as actor: CameraActor /Game/model.model:PersistentLevel.CameraActor_0
LogPython: Screenshot 1 saved at: C:/UE_PROJEKTY/model_pokoj/Screenshots/Room_Wall_1.png
LogPython: Screenshot 2 saved at: C:/UE_PROJEKTY/model_pokoj/Screenshots/Room_Wall_2.png
LogPython: Screenshot 3 saved at: C:/UE_PROJEKTY/model_pokoj/Screenshots/Room_Wall_3.png
LogPython: Screenshot 4 saved at: C:/UE_PROJEKTY/model_pokoj/Screenshots/Room_Wall_4.png
LogPython: Screenshot 5 saved at: C:/UE_PROJEKTY/model_pokoj/Screenshots/Room_Wall_5.png
LogPython: Screenshot 6 saved at: C:/UE_PROJEKTY/model_pokoj/Screenshots/Room_Wall_6.png
LogPython: Screenshot 7 saved at: C:/UE_PROJEKTY/model_pokoj/Screenshots/Room_Wall_7.png
LogPython: Screenshot 8 saved at: C:/UE_PROJEKTY/model_pokoj/Screenshots/Room_Wall_8.png
LogCore: Display: Tracing Screenshot "Room_Wall_8" taken with size: 1920 x 1080