I know why I was seeing the issue with the example. If the file is completely empty it doesn't insert the text. If there is an actual 10th line in the file it will insert.
The thing I don't get is I had some functionality that used the linefind that worked and just stopped working. It had a linefind call within a linefind (not sure if this matters) call. Like this:
Section test
${LineFind} "c:\file.txt" "c:\file.txt" "1:-1" "fileReplace"
SectionEnd
Function fileReplace
;String to search for
StrCpy $R0 "test="
${LineFind} "c:\file.txt" "/NUL" "1:-1" "FindStringInString"
;String to insert
StrCpy $R0 "test=test$\r$\n"
${LineFind} "c:\file.txt" "" "$R1" "FileTextInsert"
Push $0
FunctionEnd
;Writes the string provided in $R0
function FileTextInsert
;Write the specified string ($R0) to the file specified by linefind ($R4)
FileWrite $R4 $R0
Push $0
functionend
;Searches a given string and assignes $R1 the line number where it was found + 1
Function FindStringInString
;$R9 is the path name return by locate. It equals the path name for the current file that was found
${TrimNewLines} '$R9' $R9
;Search the current line to see if specified value is there
${WordFind} "$R9" "$R0" "+1{" $1
;If string to search is not equal to output string then line was not found.
${IfNot} $R9 == $1
;Sets the $0 to contain a string that stops
StrCpy $0 StopLineFind
;Sets $R1 with the line number found
StrCpy $R1 $R8
;Increment $R1 to the next line number
IntOp $R1 $R1 + 1
${EndIf}
;Search the next line
StrCpy $R9 "$R9$\r$\n"
Push $0
FunctionEnd
I have excluded some code to make it cleaner. The problem I have is this code worked for me before and now it doesn't. I was able to get it working by calling fileReplace directly. I do realize that the way above is unnecessary and it isn't really necessary to fix.