IBM interview question

Sort text into various files