adding sys.stdout.write call in output_records