$file = aaa.txt first time file mode open( my $testfile, "+>> $file" ) $!\n"; if ( -z "$testfile" ) ---> checking for empty file { write some o/p data close( $testfile );