Fixed bugs (truncated file) and also using csv module to read the file