Loop cannot be run normally in python lammps module

@akohlmey
Thanks for your kind reply. I am now clear about Problem 1.

For Problem 2,

Why reopen and read the file in every step? Why not read it outside the loop and be done?

They are different files. At a certain timestep, I should open the corresponding file.

What I want to assign is a time-dependent force for each atom i, i.e., F(i, t).
To assign them via variable atomfile, I stored these values in N_\mathrm{step} csv files. At each timestep t_i, I read the corresponding forces from force_{step}.csv and assigned them to each atom.
image