added code to go back in string to replace the values that point to labels to the appropriate value
made it write to the output file