in reply to Writing to a file which is external to cgi-bin directory

You forgot to open OUT.

And please use constants instead of magical numbers. Replace

seek(OUT, 0, 2);
with
use Fcntl qw( SEEK_END ); seek(OUT, 0, SEEK_END);

Update: Added the comment about using meaningful constants.