CSV weeklystats output fixed

debugged and fixed the errors that were giving trouble to properly
outputting the last column of the main file to the first column of
weekly stats