telnet config output is not complete

Hi I would like to ask if how can I make a conditional statement for waiting the output to be complete before registering it . I manage to get the config in my router using telnet but then the config output is not complete.

here is my script:

  • name: AUTOMATIC BACKUP OF RUNNING-CONFIG FOR RUIJIE
    hosts: telnet
    connection: network_cli
    gather_facts: true
    tasks:
  • name: Backup ruijie
    telnet:
    user: [username]
    password: [password]
    login_prompt: 'Username: ’
    password_prompt: ‘Password:’
    prompts:
  • “[>#]”
    command:
  • terminal length 0
  • sh run
    register: config
  • name: SAVE OUTPUT TO ./backups/
    copy:
    content: “{{ config.output[1] }}”
    dest: “./backups/{{ inventory_hostname }}-config.txt”