This example is taken from W.B.KHAN, figure 5-10, page 114.
I called the input file: payroll-in and the output file: payroll-out.
I had to make a few changes to your textbook example to make it work.
The next slides will take you step by step through the example.
The complete example is posted under the name:
Example 1: Payroll program