BTW, the other guys didn't mention this, but if you want to open the file for "appending" (meaning adding on to the end of the file, which it sounds like is maybe what you want to do), then do it like this:
open OUT, ">>filename.txt" or die("Can't open file for append!");