# PB write error!

**URL:** <https://community.freefem.org/t/pb-write-error/1316>\
**Category:** General Discussion\
**Created:** [November 9, 2021, 10:23am UTC](https://community.freefem.org/t/pb-write-error/1316 "2021-11-09T10:23:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![xiaojiemo](https://avatars.discourse-cdn.com/v4/letter/x/a4c791/32.png) [@xiaojiemo](https://community.freefem.org/u/xiaojiemo)\
**Post date:** [November 9, 2021, 10:23am UTC](https://community.freefem.org/t/pb-write-error/1316/1 "2021-11-09T10:23:59Z")

</div>

hello,everyone, I want to output the data to a file and I wrote following code,  
{  
ofstream out(“setaf.txt”);  
out\<\<setaf[];  
}  
savemesh(th2,“th2.msh”)  
the procedure exect due to “PB write error”. what’s wrong with it and how to fix it?

---

<div class="post-metadata">

**Author:** ![jsmacd](https://avatars.discourse-cdn.com/v4/letter/j/df788c/32.png) [@jsmacd](https://community.freefem.org/u/jsmacd)\
**Post date:** [January 30, 2023, 8:49pm UTC](https://community.freefem.org/t/pb-write-error/1316/2 "2023-01-30T20:49:08Z")

</div>

Did you figure this out? I’m dealing with this error right now as well.

---

<div class="post-metadata">

**Author:** ![jsmacd](https://avatars.discourse-cdn.com/v4/letter/j/df788c/32.png) [@jsmacd](https://community.freefem.org/u/jsmacd)\
**Post date:** [January 30, 2023, 9:34pm UTC](https://community.freefem.org/t/pb-write-error/1316/3 "2023-01-30T21:34:49Z")

</div>

Ok I figured out the problem that was happening for me, you have to save mesh with a _.mesh_ file extension.

---

<div class="post-metadata">

**Author:** ![haiyang-liu-19](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/haiyang-liu-19/32/1864_2.png) [@haiyang-liu-19](https://community.freefem.org/u/haiyang-liu-19)\
**Post date:** [August 17, 2023, 4:04pm UTC](https://community.freefem.org/t/pb-write-error/1316/4 "2023-08-17T16:04:44Z")

</div>

Thank you so much! I meet the same problem, after use your approach, the code run correctly!
