Fixing bugs in read_text_file()