I keep getting the error that my filehandle is closed.
If I may be so bold.... The errors you should
be getting from your posted code look like this:
No such class OUT at pm-889248 line 5, near "open(my OUT"
syntax error at pm-889248 line 5, near "my OUT,"
No such class IN at pm-889248 line 6, near "open(my IN"
syntax error at pm-889248 line 6, near "my IN,"
Note that these are not
errors about closed file handles.
Now, I humbly suggest that you follow the advice given by Corion
and (re?)read the documentation they point you to.