cleanup file reader and writer, pass cmd to rules