We were extracting some data into text file and then we noticed the above error. I checked many things, everything seemed ok. I realized that i get this error only for certain write operations when length of buffer was more than 1024. We had used following call to open file
Since 4th parameter to UTL_FILE.fopen was not passed, it was defaulted to 1024. Hence the error when buffer was more than 1024.
Solution: we changed the call to UTL_FILE.fopen and passed 4th parameter max_linesize as 32767.