refactoring the numbered_cat method
added ability to support both stdin and files