You can get the joystick position and convert it to a string and output that to the file
Code:
joy_pos = str(joy.getPosition())
# Create the output string
out = str('current position' + '\t' + joy_pos + '\n')
# Write the string to the output file
file.write(out)
# Makes sure the file data is really written to the harddrive
file.flush()