Using pointers to read and write text files