R: how to print out the bad line number during parsing
<p>I have a fixed width file that I am reading in this way:</p>

<pre><code>library(readr)
mydata &lt;- read.fwf(file="myfile.txt", widths = c(12, 7, etc))
</code></pre>

<p>It returns:</p>

<pre><code>Error in substring(x, first, last) : 
  invalid multibyte string at '&lt;cd&gt;S    '
</code></pre>

<p>As the file is pretty big I would like to find out what is the line number in the file that returns the error. How can I get that using R?</p>