fixed bug in vector generation
write output to files