Hello everyone,
I am new at this site so please bare with me. I have an assignment to read characters one by one from one text file and write them to another text file using post script. I am to the point where I can read line by line from a text file and write the line to another.

This version works...

%!PS

/infile (input.txt) (r) file def % open files and save file objects
/outfile (output.txt) (w) file def
/buff 128 string def % your buffer for reading operations
{ % loop
infile buff readstring
{ %ifelse
outfile exch writestring
}
{ %else
outfile exch writestring
infile closefile
outfile closefile
exit % exit the loop
} ifelse
} bind loop


But when i try to read individual characters I get an error saying its typemismatch and i am unsure how to resolve it.

Here is the code:


/infile (input.txt) (r) file def % open files and save file objects
/outfile (output.txt) (w) file def
/buff 1 string def % your buffer for reading operations
{ % loop
infile buff read
{ %ifelse
outfile exch write
}
{ %else
outfile exch write
infile closefile
outfile closefile
exit % exit the loop
} ifelse
} bind loop


Any help would be greatly appreiated thanks!
Ryan