Adding commands and writing it in a file