How to save my output?

Hello everyone,
I am trying to save my output in a file with all relevant data per each trial. Would you please tell me how to do it in a very simple language? Thank you very much.

#import the libraries
from psychopy.visual import Window
from psychopy import core, visual
from psychopy.event import getKeys
from psychopy.event import waitKeys
import psychopy.visual
import psychopy.event
from psychopy.visual import Window, TextStim
from psychopy.core import wait, Clock
from psychopy.visual import RatingScale
import random
from psychopy.visual import RatingScale
from psychopy.core import wait, Clock
from psychopy.misc import fromFile

#Instruction
#creat a window
my_win = Window( [600,600], color=‘black’, fullscr=False)
#Creat the first text
my_text = TextStim( my_win, text=‘welcome to our experiment!’, alignText=‘center’ )
#creat the timer
timer= Clock()
while timer.getTime() < 2:
my_text.draw()
my_win.flip()

#creat the second text
my_text = TextStim( my_win, wrapWidth = 1.8, height = 0.09, text=‘After reading the presented resume, then hit the space key to see the rating bar. Use your computer mouse to rate the resume. \n Now, press the space key to start the experiment.’ )
my_text.draw()
my_win.flip()
waitKeys( keyList = [ ‘space’ ] )

thisExp.saveAsWideText(filename+’.csv’)
thisExp.saveAsPickle(filename)

#Priming phase#
#create a for loop to repeat the trial
for i in range (2):

#creat the window
win=psychopy.visual.Window ([600,600], fullscr=False, color='black')
#import image (fixation cross)
img= psychopy.visual.ImageStim  (win=win, image="cross.png",  units='norm', size=[2,2])
timer= Clock()
while timer.getTime() < 0.5:
    img.draw()
    win.flip()

#create a window
win = psychopy.visual.Window ([600,600], fullscr=False, color= ‘black’)
#import images
images= [“neutral_face.jpg”, “happy_face.jpg”, “sad _face.jpg”]
index = random.randint(0, 2000)%3
var1 = images[index]
img= psychopy.visual.ImageStim (win=win, image=var1, units=‘norm’, size=[2,2])
timer= Clock()
while timer.getTime() < 0.001:
img.draw()
win.flip()
#create a window
win = psychopy.visual.Window ([600,600],fullscr=False, color=‘black’)
#import image (noise)
mask= ‘C:\Users\Hakimeh\OneDrive\Desktop\New folder (2)’
img= psychopy.visual.ImageStim (win=win, image=“mask.jpg”, units=‘norm’, size=[2,2])
timer= Clock()
while timer.getTime() < 0.03:
img.draw()
win.flip()
images= [“resume1.jpg”, “resume2.jpg”, “resume3.jpg”]
index = random.randint(0, 2000)%3
var2 = images[index]

#rating scale
win=psychopy.visual.Window ([600,600], fullscr=False,checkTiming=True, color=‘black’, units= ‘pix’)
my_rating = visual.RatingScale(win, low=0, high=100, labels= (‘no’, ‘yes’), stretch = 1, lineColor = ‘Black’, scale= ‘rating’, markerColor = ‘Black’, textColor = ‘Black’, singleClick = True, mouseOnly = True, pos = (100, -170))
item= psychopy.visual.ImageStim (win=win, image=var2, units=‘norm’, size=[2,2])

for k in images:
    my_rating.setDescription(scale = k)
    my_rating.reset() 
while my_rating.noResponse:
    item.draw()
    my_rating.draw()
    win.flip()

rating = my_rating.getRating()
decisionTime = my_rating.getRT()
output= [var1,var2, rating, decisionTime]
print (output)

my_win = Window( [600,600], color=‘black’, fullscr=False)
#The first text
my_text = TextStim( my_win, text=‘thank you for participating in our experiment!’, alignText=‘center’ )

timer= Clock()
while timer.getTime() < 3:
my_text.draw()
my_win.flip()

#output_file = open (“Imagecross1.py”, “a”)

#outputs= output_file.readlines ()
#for output in outputs:

print (output)

#output_file.close()
#saving output
#output_file = open (“Imagecross1.py”, “a”)

#output= output_file.readlines ()
#for o in output:
#print (o)
#output_file.close()