use IO::Socket; @colors = qw(pink yellow blue green); open(COLORS, ">>colors.txt") or die $!; # turn off stdio buffering on COLORS COLORS->autoflush(1); foreach $color (@colors){ print COLORS "$color\n"; print "sending $color to File\n"; } while () { chomp; exit if ($_ eq "quit"); print COLORS $_; }