open (FH, "; close (FH); $newline = "The new line of text to go at the top of the file"; open (NFH, ">filename.txt") || die "could not open file 2: $!"; print NFH "$newline" . "\n"; foreach $line (@ODB) { print NFH "$line"; } close (NFH);