Error in dihedral scan

I want to do a relaxed dihedral scan. It failed with an error "Could not converge geometry optimization in 50 iterations“
Could you help me to fix it? Thank you.
The output file is too large to upload.
Here is the error info:

PsiException: Could not converge geometry optimization in 50 iterations.


Traceback (most recent call last):
  File "/root/psi4conda/bin/psi4", line 387, in <module>
    exec(content)
  File "<string>", line 132, in <module>
  File "/root/psi4conda/lib/python3.9/site-packages/psi4/driver/driver.py", line 1356, in optimize
    raise OptimizationConvergenceError("""geometry optimization""", n - 1, wfn)

psi4.driver.p4util.exceptions.OptimizationConvergenceError: Could not converge geometry optimization in 50 iterations.


Printing out the relevant lines from the Psithon --> Python processed input file:
        m01.d8 = A
        core.set_global_option("BASIS", "6-31G*")
        core.set_global_option("SCF_TYPE", "df")
        core.set_global_option("GUESS", "sad")
        core.set_local_option("OPTKING", "FROZEN_DIHEDRAL", "(""          2 3 5 8        "")")
-->     optimize('scf')
        core.set_global_option("BASIS", "6-311+G**")
        core.set_global_option("SCF_TYPE", "df")
        core.set_global_option("GUESS", "sad")
        b3lyp_energy_ht = energy ('b3lyp') 
        b3lyp_energy_kc = energy ('b3lyp') * psi4.constants.hartree2kcalmol  

Below is my input file:

molecule m01 {
0 1
Cl
C  1  r2
C  2  r3  1  a3
C  2  r4  1  a4  3  d4
N  3  r5  2  a5  1  d5
C  3  r6  2  a6  1  d6
C  4  r7  2  a7  1  d7
C  5  r8  3  a8  2  d8
C  5  r9  3  a9  2  d9
C  7  r10  4  a10  2  d10
O  8  r11  5  a11  3  d11
C  8  r12  5  a12  3  d12
N  9  r13  5  a13  3  d13
C  9  r14  5  a14  3  d14
C  12  r15  8  a15  5  d15
C  13  r16  9  a16  5  d16
C  14  r17  9  a17  5  d17
C  17  r18  14  a18  9  d18
H  4  r19  2  a19  1  d19
H  6  r20  3  a20  2  d20
H  7  r21  4  a21  2  d21
H  10  r22  7  a22  4  d22
H  17  r23  14  a23  9  d23
H  18  r24  17  a24  14  d24
H  16  r25  13  a25  9  d25
H  15  r26  12  a26  8  d26
H  12  r27  8  a27  5  d27
}

m01.r2= 1.7315
m01.r3= 1.4067
m01.a3= 121.64
m01.r4= 1.3964
m01.a4= 118.75
m01.d4= 179.83
m01.r5= 1.4157
m01.a5= 121.26
m01.d5=   0.10
m01.r6= 1.4012
m01.a6= 119.72
m01.d6= 179.31
m01.r7= 1.3948
m01.a7= 120.37
m01.d7= 180.37
m01.r8= 1.3803
m01.a8= 116.90
m01.r9= 1.4375
m01.a9= 118.58
m01.d9=  88.94
m01.r10= 1.3942
m01.a10= 120.08
m01.d10=   0.10
m01.r11= 1.2340
m01.a11= 125.38
m01.d11= 359.56
m01.r12= 1.4567
m01.a12= 114.39
m01.d12= 179.56
m01.r13= 1.3664
m01.a13= 119.48
m01.d13=   0.11
m01.r14= 1.4062
m01.a14= 119.12
m01.d14= 180.26
m01.r15= 1.3480
m01.a15= 123.98
m01.d15=   0.52
m01.r16= 1.3577
m01.a16= 118.39
m01.d16= 180.20
m01.r17= 1.3968
m01.a17= 119.46
m01.d17= 179.85
m01.r18= 1.3956
m01.a18= 119.13
m01.d18= 359.97
m01.r19= 1.0803
m01.a19= 120.05
m01.d19=   0.30
m01.r20= 1.0806
m01.a20= 120.33
m01.d20= 180.38
m01.r21= 1.0799
m01.a21= 119.95
m01.d21= 179.99
m01.r22= 1.0801
m01.a22= 120.00
m01.d22= 179.89
m01.r23= 1.0804
m01.a23= 120.77
m01.d23= 180.01
m01.r24= 1.0801
m01.a24= 120.68
m01.d24= 180.01
m01.r25= 1.0800
m01.a25= 116.40
m01.d25= 179.93
m01.r26= 1.0806
m01.a26= 119.43
m01.d26= 179.97
m01.r27= 1.0805
m01.a27= 117.45
m01.d27= 180.43


Avals=range(0,365,5)

rows = []
table = []

for A in Avals:
    m01.d8 = A
    set {
        basis 6-31G*
        scf_type df
        guess sad
    }
    set optking {
        frozen_dihedral = ("
          2 3 5 8
        ")
    }
    optimize('scf')
    set {
        basis 6-311+G**
        scf_type df
        guess sad
    }
    dft_energy_ht = variable('DFT TOTAL ENERGY')
    dft_energy_kc = variable('DFT TOTAL ENERGY') * psi_hartree2kcalmol
    rows.append(A)
    table.append([dft_energy_ht, dft_energy_kc])

import pandas as pd
df = pd.DataFrame(table, columns = ["dft_energy_ht", "dft_energy_kc"], index=rows)
print(df)