Creating and writing files depending on the input data