Removing unneeded debug line and writing output to a file.