added writeToTab arg, changed data format