My code is : http://pastebin.com/rCy4wSUK
As soon as this function is called by router it prints "done copying contents of clean base into temp" and then error which is here: http://pastebin.com/UxEu4PaS
So at least it is not giving an error in copying but what is causing it to throw this error.