请问大佬们为什么我这个创建打开不了文件?

#include<stdio.h>
int main(void)
{
    FILE *fp;
    char ch;
    if((fp=fopen("d:\\text.txt","wt"))==NULL);
    {
        printf("cannot open file!\n");
        getchar();
    }
    printf("输入字符:");
    while((ch==getchar())!='\n')
        fputc(ch,fp);
    getchar();
    return 0;
}

图片说明
大佬们我是新人,请问为什么文件创建打开失败了啊
然后不管输入什么,包括回车都无法结束程序

if((fp=fopen("d:\\text.txt","wt"))==NULL);

后面多了分号

while((ch==getchar())!='\n')

ch == getchar() 写错了。