using stdout.write instead of print for table printing