How to include form for WP_Filesystem()?

First, remove that bit up front about calling WP_Filesystem(); by itself. You need to request_filesystem_credentials first, before invoking that.

Second, you need to use the $wp_filesystem->wp_themes_dir('themename') function call to get the proper “remote” directory, in order to be able to properly call the put_contents() function with the right filename. The “remote” directory won’t necessarily match the “local” directory, and get_template_directory() is absolutely the wrong way to get that file path for remote writing. It’s fine for local file checking though.