fixed while loop to read spaces using fgets