infinite loop, fgets and feof only works with stream or socket