A file existed, and contained my name, after making the following changes and rebuilding/running the program:
(see comments in line for reasons)
Change:
if(x = NULL)//assignment - as is, this statement will always evaluate
//to false, as x is assigned to NULL.
To:
if(x == NULL)// comparison - this will test whether x is equal to NULL without changing x.
Change: (this was key to your file not being populated)
scanf("%s", &name);//the 'address of' operator: '&' is not needed here.
//The symbol 'name' is an array of char, and is
//located at the address of the first element of the array.
To:
scanf("%s", name);//with '&' removed.
Or better:
scanf("%24s", name);//'24' will prevent buffer overflows
//and guarantee room for NULL termination.
Yet one more method to address the comment about not using scanf at all...:
char buffer[25];//create an additional buffer
...
memset(name, 0, 25);//useful in loops (when used) to ensure clean buffers
memset(buffer, 0, 25);
fgets(buffer, 24, stdin);//replace scanf with fgets...
sscanf(buffer, "%24s", name);//..., then analyze input using sscanf
//and its expansive list of format specifiers
//to handle a wide variety of user input.
//In this example, '24' is used to guard
//against buffer overflow.
Regarding the last method, here is a page detailing the versatility of handling user input strings using sscanf.