Creating commands and writing in file