To open a file for writing, prepend the file name with the > prefix $fName = "/the/path/to/the/filename"; open( MYOUTPUT, ">$fName" ); To write one line at a time to the file print MYOUTPUT "Hello World\n";