read from file and output to file