Implemented Factory design pattern for input/output.