IF ELSE not working

First, love this piece of software. It's been a great help! If I wasn't in college and had a real job, I'd definitely pay for the full version.

I'm having some trouble with my script. I'm scrapping a page that creates a link for comments if they're over a certain length, but doesn't if they're not. To keep from writing the data to a file twice, I have two extractor patterns. The first checks for a link and sends screen-scraper to a new page that scrapes the data. The second scrapes the data off the first page, but is setup so that if a link is present in the data it can't extract the variable "COMMENT". In the script that writes the data to a file I want to include a short if else function to check whether the variable "COMMENT" is null or not. Here's my code, hopefully it makes sense.

At the moment it just runs to the else section and ends.

if (session.getVariable("COMMENT") != null )
{
FileWriter out = null;

try
{

// Open up the file to be appended to.
OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream("edu_comments.txt", true),"UTF-8");

// Write out the data to the file.
out.write( dataRecord.get( "ALIAS" ) + "\t" );
out.write( dataRecord.get( "TITLE" ) + "\t" );
out.write( dataRecord.get( "COMMENT" ) + "\t" );
out.write( dataRecord.get( "DATE_TIME" ) );
out.write( "\n" );

session.log( "Data writen to file." );

session.setVariable( "COMMENT", null );

// Close up the file.
out.close();
}
catch( Exception e )
{
session.log( "An error occurred while writing the data to a file: " + e.getMessage() );
}
}

else
{
session.log( "Write file skipped." );
}

session variable

So, I just wanted to check that you're saving the ~@COMMENT@~ in the extractor pattern as a session variable. I realize that's probably a stupid question, but it is going to be important here.

Or if you are calling this script from the same datarecord that ~@COMMENT@~ is in you could do dataRecord.get("COMMENT");

Aside from that the rest of the script seems quite solid.

scraper