replaced low-level stext reading with an fgets call