Made the file writing better

Now it only prints those clock cycles where some changes happen.
Files are named same as the input.