I have a code which appends word positions to the words from the source file but the output is not coming as desired: