def remove_comments(input_file, output_file): with open(input_file, 'r') as infile, open(output_file, 'w') as outfile: for line in infile: cleaned_line = line.split('--')[0].rstrip() # Remove comment and trailing whitespace if cleaned_line: # Check if the line is not empty outfile.write(cleaned_line + '\n') if __name__ == "__main__": import sys if len(sys.argv) != 3: print("Usage: python remove_comments.py ") sys.exit(1) input_file = sys.argv[1] output_file = sys.argv[2] remove_comments(input_file, output_file)