It's overwriting the file that it's also trying to read from. If the converted form is longer than the original, the output will catch up to the input, and then it will try to convert what it has already converted.
It's surprising that it works at all. Most programs truncate their output file before writing, so there wouldn't be anything for it to read from.