Recently I was creating an SSIS script task that needed to read and write to variables. After doing some research, I found some code at this site which simplifies the task.
The code includes a function called ReadVariable which reads in the value of a variable, as well as subroutine called WriteVariable, which writes a value to a variable. I personally prefer using these routines, as you avoid having to configure the ReadOnlyVariables and ReadWriteVariables attributes of the script task, leaving everything in the code of the script.