First line of sub before loop
<p>This function breaks up one long continuous string into smaller ones and adds a prefix and suffix/</p>

<p>This line of code is giving me problems I need it because the first prefix is different to the others but it causes the first line to be produced twice not sure how to rewrite the line /code overcome this?</p>

<pre><code>.WriteLine "s = """ &amp; Trim$(Mid$(strInput, 1, intSize * AtomSize)) &amp; """"
</code></pre>

<p>Here is the full suc:</p>

<pre><code>Sub StringBuilder(intSize As Integer, Optional AtomSize As Long = 3)
Dim i As Long
Dim strInput As String

strInput = CreateObject("Scripting.FileSystemObject").OpenTextFile(CurrentProject.Path &amp; "\input.txt").ReadAll
With CreateObject("Scripting.FileSystemObject").CreateTextFile(CurrentProject.Path &amp; "\output.txt", True)
    .WriteLine "s = """ &amp; Trim$(Mid$(strInput, 1, intSize * AtomSize)) &amp; """"
  For i = 1 To Len(strInput) - intSize * AtomSize Step intSize * AtomSize
    .WriteLine "s = s &amp; """ &amp; Trim$(Mid$(strInput, i, intSize * AtomSize)) &amp; """"
  Next
  .WriteLine "s = s &amp; """ &amp; Trim$(Mid$(strInput, i, intSize * AtomSize)) &amp; """"
End With

End Sub
</code></pre>