Hi and welcome,
Since this is for an assignment I will not post any code.
I had a quick look at your code and there seams to be a number of of errors.
The first error I spotted is never use the function gets(), it is error prone and a security risk, use fgets() instead.
Next you are trying to have your own busy loop around gtk_main() and test(). This is the incorrect way to use it as gtk_main() is the main event loop for your application.
There are two ways to to monitor file IO within the gtk_main() event loop. Firstly using g_io_channel functions http://developer.gnome.org/glib/stable/glib-IO-Channels.html
These are the basic functions you will need
// Linux etc...
GIOChannel * g_io_channel_unix_new (int fd);
GIOChannel * g_io_channel_win32_new_socket (gint socket);
// connect a callback to the channel to watch and what to watch for, ie.
guint g_io_add_watch (GIOChannel *channel,
// This is the prototype for your callback
gboolean (*GIOFunc) (GIOChannel *source,
Secondly directly in the main loop http://developer.gnome.org/glib/stable/glib-The-Main-Event-Loop.html
This is a much more complex API and I would advise the use of GIO functions instead.
Hope this is a pointer in the right direction. If you need any more help after giving it a try then please as again.