Added logic to not print the extra newlines after the last testcase. WA even now.