How to preserve correct offset of string which is read from a file
===

I have a text.txt file which contains following txt.

     Kontagent Announces Partnership with Global Latino Social Network Quepasa
     
     Released By Kontagent


I read this text file into a string documentText.

`documentText.subString(0,9)` gives `Kontagent`, which is good.

But, `documentText.subString(87,96)` gives  `y Kontage` in windows (IntelliJ Idea) and gives `Kontagent` in Unix environment. I am guessing it is happening because of blank line in the file (after which the offset got screwed). But, I cannot understand, why I get two different results. I need to get one result in the both the environments.

To read file as string I used all the functions talked about here
http://stackoverflow.com/questions/326390/how-to-create-a-java-string-from-the-contents-of-a-file . But, I still get same results after using any of the functions.


Currently I am using this function to read the file into documentText String:


    public static String readFileAsString(String fileName)
    {

        File file = new File(fileName);
        StringBuilder fileContents = new StringBuilder((int)file.length());
        Scanner scanner = null;
        try {
            scanner = new Scanner(file);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        String lineSeparator = System.getProperty("line.separator");

        try {
            while(scanner.hasNextLine()) {
                fileContents.append(scanner.nextLine() + lineSeparator);
            }
            return fileContents.toString();
        } finally {
            scanner.close();
        }
    }