open (FH3, ">lessons.txt"); ### You should *always* check the return from any calls to the system. open FH3, ">lessons.txt" or die "lessons.txt: $!\n"; ### You should also close this filehandle; don't assume that your file has actually ### been written before you do so! close FH3; $l="lessons.txt"; open(FH3, $l) || die("Could not open file!"); ### Don't create variables that you're only going to use once; just use the value. ### *And* check the return of the call. And don't pre-assume the reason for failure: ### find out what it is with the '$!' (actual error) variable. open FH3, "lessons.txt" or die "lessons.txt: $!\n";