Safely editing core files

There is no “safe” way to edit core files; if you do you will need to check and repeat the edition after every update. Not recommended at all.

Instead of editing core files, you could use any of the actions and filters available. For example, pre_comment_on_post (example code not tested):

add_action( 'pre_comment_on_post', function( $post_id ) {

    if( $post_id ) {

        $comment_content = ( isset($_POST['comment']) ) ? trim($_POST['comment']) : null;

        if ( '' == $comment_content ) {

            // Redirect to post if comment content is empty
            wp_redirect( get_permalink( $post_id ) );
            exit;

        }

    }

} );