Use write instead of writelines