getSourceFp(); $destinationFp = $this->getDestinationFp(); $index = $this->getIndex(); $writtenCount = 0; foreach ($index as $identifier => $positions) { if (count($positions) === 1) { // No duplicate. rewind($sourceFp); fseek($sourceFp, $positions[0]); $sourceData = fgetcsv($sourceFp); fputcsv($destinationFp, $sourceData); $writtenCount++; } } return new Report( Report::TYPE_INFO, "${writtenCount} records written in file '" . realpath($this->getDestination()) . "'." ); } }