file copy by reading char by char until it reaches EOF