Fixed file reading by rewritting everything