Replaced gets () with fgets ()