Are you sure that the line(s) contains only "\n" and not "\r\n"? If you're using Windows then your file may contain "\r\n" (CR-LF / carriage-return, line-feed) instead, in which case your test wouldn't work.
Are you sure that the line(s) contains only "\n" and not "\r\n"? If you're using Windows then your file may contain "\r\n" (CR-LF / carriage-return, line-feed) instead, in which case your test wouldn't work.
Whether there is a carriage return or not doesn't matter. \r and \n are two different characters so OP's code, since it searches for '\n', would work.
Univcplus you are looping through the file's size but are checking two strings? Can you show full code?