problem with loops and voids and saving outputs in a SD card