Since I hand't messed around with files yet in ComputerCraft, I thought I would duplicate your scenario and see what was happening. I simplified it down a bit and wrote the following code:
local fileName = "myFile"
local line
local userInput = read()
if fs.exists(fileName) then
local hRead = fs.open(fileName,"r")
line = hRead.readLine()
hRead.close()
else
print ("File "..fileName.." does not exist. Program exiting…")
return
end
if line==userInput then
print("User Input and File Content matches."
else
print("User Input and File Content Error:"
print("User Input -->"..userIntput.."<--")
print("File Content-->"..line.."<--")
end
I am placing a minimal amount of error checking in my code. I print a message and quit the program if the file does not exist. I also will print what the user typed and what the file contained if there is a mismatch.
I then created a file named myFile and edited it to contain the following line:
surferpup wuz here
I ran the code and it worked perfectly. If I messed up the file name it printed a message and quit. If I typed in what was read from the file it worked. If I typed something different it worked. I tried a file with only one line (no end-of-line). I tried multiple line files. I tried data with and without capital letters. I also tried it with your values -- I used "Hayden" with quotes and without for both the file data as well as the user input. Worked fine. Everything worked exactly as expected. Please check your code. Or, copy mine and test it yourself.
Edited by surferpup, 22 January 2014 - 09:18 PM.