How to convert xgboost output to csv?

I am a newbie to r and xgboost

I have

   traindata <- read.csv("Regression_train.csv" )
   trainmatrix <-as.matrix(traindata)
   bst <- xgboost(data = trainmatrix, label = trainmatrix[,"target"], max.depth = 2, eta = 1, nthread = 2, 
   nrounds = 2, objective = "reg:squarederror",verbose=2 )

but the output appears not to be .csv

How do I covert the output to a format that I can use with predict?

When I run the current format I get

Error in predict.xgb.Booster(bst, testdata): Feature names stored in object and newdata are different!

This looks relevant to my question