Since this is part of an assignment, why don't I just give the pseudocode.
- Open the input file (using open or IO::File).
- While we haven't reached the end of the input file,
- Read a line in.
- If we haven't opened an output file yet, or if we've read MAX lines, open a new output file.
- Write the line out.