if ( is_writable( $filename ) ) {
    if ( !file_put_contents( $filename, $content ) ) {
        throw new FileNotWritableException( $filename, $content );
    }
}