plot via for loop and save modified file

Hi, I want to plot for each file in a folder after performing some operations on the file in a for loop

The problem I am facing is that the plots are not with a trend rather fixed on line and the output is also just number 11111 for column V1and NaN for column Cycle_number. Conf0, conf1.... etc are file names.
I want to save the modified file as a csv after modification for which I am using append.

all_paths <-
  list.files(path = "/content/shear2",
             pattern = "*.*",
             full.names = TRUE)

all_filenames <- all_paths %>%
  basename() %>%
  as.list()

all_content <-
  all_paths %>%
  lapply(read.table,
         header = TRUE,
         skip=60,
         sep=',',
         encoding = "UTF-8")


file <- data.frame()

for (i in 1:length(all_filenames)) {

    all_lists <- mapply(c, all_content, i, SIMPLIFY = FALSE)

    data <- rbindlist(all_lists, fill = T)

    names(data)[1] <- "File.Path"

        # generating modified dataframe `x` from the main dataframe named `data` and performing some operations on it. 

    x <- data %>% data.frame(str_split_fixed(data$File.Path, " ", 23))%>% select(-c(File.Path))
    x<-x[-c(1:53), ]
    x1 <- x %>% select(V1) %>% unique()
    x<- x%>% filter(X1=='Interactions')
    x<- cbind(x1,x)
      
    x <- x %>% mutate(Cycles = case_when(V1 %in% c("conf0","conf1","conf2","conf3","conf4","conf5","conf6","conf7","conf8","conf9","conf10")~"1st Amplitude",TRUE~"2nd amplitude"))


    x<- x %>% mutate(Cycle_number = case_when(V1== "conf0"~1,V1=="conf1"~1,V1=="conf2"~2,V1=="conf3"~3))

    Z<- (2*x$X2)/20005

    x <- x %>% mutate(Coordination_number = Z)

# saving csv with interactions only
    file <- write.csv(x,"/content/sheartest-1_interactions.csv",row.names = T)
# appending file to save as a dataframe
    file <- append(file,x)


# plotting for some variables in the modified dataset x
 p<-  ggplot(x) +
  aes(Cycle_number, X2) +
  geom_point(shape = "circle", size = 3.6, colour = "#112446") +
  geom_smooth(span = 0.75) +
 labs(x = "Cycles number", y = "Interactions")
 ggsave("1.png",dpi=300)

 print(p)


  png("my_plot1.png")
  plot(Z,x$Cycle_number, xlab="Cycle number", ylab="Z")
  dev.off()

 ggplot(x) +
 aes(V1 , Coordination_number) +
  geom_point(shape = "circle", size = 3.6, colour = "#112000") +
  labs(x = "Time", y = "Z*")
 ggsave("2.png",dpi=300)


   png("my_plot.png")
    plot(x$Coordination_number,x$Cycle_number,xlab="Cycles",ylab="Z*",type = "p",pch=18,cex=3,cex.lab=1.8)
    #Closing the graphical device
    dev.off()

    
}