Excel file not being saved

Although the program is running perfectly, the output file is not being saved. Is there anything wrong with the way I’m saving the file? Or could it be something else?

xlsxFileName = infoSujeto['Código'] + infoSujeto['Fecha'] + '.xlsx'
trials.saveAsExcel(fileName=xlsxFileName,
                   sheetName='rawData',
                   stimOut=[],
                   dataOut=['all_raw'], appendFile=True)

This is the full code in case is needed:

#Importa las bibliotecas necesarias
import os
import pandas as pd
import numpy as np
import random
from psychopy import visual, event, core, data, gui

event.globalKeys.add(key='escape', func=core.quit, name='shutdown')

#Crea el cuadro de diálogo con la info del participante
infoSujeto = {'Código':'','Edad':'', 'Sexo':''}
dlg = gui.DlgFromDict(infoSujeto, title='Configuración del experimento')
if not dlg.OK:
    core.quit()
infoSujeto['Fecha'] = data.getDateStr()
    
#Crea una ventana emergente
win = visual.Window([1440,900], fullscr=True, units='pix', color = 'white')

inst = visual.TextStim(win, text='Lorem Ipsum', color='black', height=70, wrapWidth=1500)
cambiarTrial = visual.TextStim(win, text='Presione cualquier tecla para continuar', color='black', height=70, wrapWidth=1500)

respClock = core.Clock()

dir_actual = os.path.dirname(os.path.abspath(__file__))
conditions = data.importConditions(os.path.join(dir_actual, 'conditions.csv'))

trials = data.TrialHandler(trialList=conditions, nReps=1, method='sequential')
bloques = np.unique([trial['Block'] for trial in conditions])

for bloque in bloques:
    inst.draw()
    win.flip()
    instKeys = event.waitKeys(keyList=['space','escape'])
    if 'escape' in instKeys:
        core.quit()
    trialsBloque = [trial for trial in conditions if trial['Block'] == bloque]
    opciones = [trial['Correct'] for trial in trialsBloque]
    random.shuffle(trialsBloque)
    
    for trial in trialsBloque:
            
        mainImg = visual.ImageStim(win, image=trial['Image'], pos=(0, 350), size=(500,None))
        corr = trial['Correct']
        for opcion in opciones:
            if opcion == corr:
                opciones.remove(opcion)
        random.shuffle(opciones)
        opciones = opciones[0:3]
        opciones.append(corr)
        random.shuffle(opciones)
        img1, img2, img3, img4 = [visual.ImageStim(win, image=opcion) for opcion in opciones]

        espOcupado = img1.size[0]+img2.size[0]+img3.size[0]+img4.size[0]
        sepStim = (2880-espOcupado)/5
        distAcum = 0
        
        for i, img in enumerate([img1, img2, img3, img4]):
            escalaOpc = 320/max(img.size)
            img.size = (img.size[0]*escalaOpc, img.size[1]*escalaOpc)
            img.pos[0] = distAcum + sepStim + (img.size[0]/2) - 1440
            distAcum += sepStim + img.size[0]
            img.pos[1] = -580+img.size[1]/2
                    
        mainImg.draw()
        img1.draw()
        img2.draw()
        img3.draw()
        img4.draw()
        win.flip()
        
        while True:
            mouse = event.Mouse()
            mouseResp, respTime = mouse.getPressed(getTime=True)
            if mouseResp[0] and any([img.contains(mouse.getPos()) for img in [img1, img2, img3, img4]]):
                for i, img in enumerate([img1, img2, img3, img4]):
                    if img.contains(mouse):
                        resp = opciones[i]
                        respCorr = 1 if resp == corr else 0
                        trials.addData('resp', resp)
                        trials.addData('respCorr', respCorr)
                        trials.addData('RT', respTime)
                break        
                    

xlsxFileName = infoSujeto['Código'] + infoSujeto['Fecha'] + '.xlsx'
trials.saveAsExcel(fileName=xlsxFileName,
                   sheetName='rawData',
                   stimOut=[],
                   dataOut=['all_raw'], appendFile=True)

# Cerrar la ventana al final del experimento
win.close()
core.quit()
``