To write image file into text format using pytesseract.image_to_string, I am using below code. It is only writing last lne of the image into out file, instead of entire data.
try:
from PIL import Image
except ImportError:
import Image
import pytesseract
# Simple image to string
text=print(pytesseract.image_to_string(Image.open('test.jpg'),lang="eng"))
with open('out.txt', 'w') as f:
print(text, file=f)
