Need Help - [EDIT: Nevermind]

Hi. I don't know how to describe my problem elegantly, so I will just paste some examples of my problem. Thanks.

Bad CSV output

CATEGORY|NAME|DESCRIPTION|URL|IMAGEURL|KEYWORDS|
cat1|null|null|URL|null|null|
|||URL2|||
||||||
cat2||||||
|Some Name5|Description|URL5|ImageURL|kws|
|Some Name6|Description|URL6|ImageURL|kws|
|||URL7|||
|||URL8|||

How it should look:

CATEGORY|NAME|DESCRIPTION|URL|IMAGEURL|KEYWORDS|
cat1|Some Name|Description|URL|ImageURL|kws|
cat1|Some Name2|Description|URL2|ImageURL|kws|
cat2|Some Name3|Description|URL3|ImageURL|kws|
cat2|Some Name4|Description|URL4|ImageURL|kws|
cat2|Some Name5|Description|URL5|ImageURL|kws|
cat3|Some Name6|Description|URL6|ImageURL|kws|

EDIT ....snip....
EDIT ....snip....

(I am using the export to csv that I found in the repository - but removed the double quotes surrounding the "cell data", and made the delimiter a pipe.)

EDIT: You know what, that script from the repository has me clearing out my session variables. WELL that's the problem, they are getting cleared out when I NEED them to keep their last values!!!