is_writable() tells you whether you can write to a file.
<? if ( is_writable( "data.txt" ) ) { print "data.txt is writable"; } ?>